Code Arranger Game

It is not. You’d get an error after the else.

2 Likes
uwu = input('Come on lets go for uwu!! party! uwu!')
match uwu:
  case 'uwu!':
    print('OWO')
  case 'UWU!':
    print('Blush')

@Idkwhttph point, please.

5 Likes

Yesh yesh
i actually learnt how to use match and case from one of your replies

2 Likes

I’ll think of a challenge tomorrow, I’m going to sleep.

3 Likes

Oh, sorry, didn’t read the indentation.

1 Like

How can I know if it’s my turn?

1 Like

There is no turn.
When a player solves that puzzle, that player gets to make the nxt puzzle
each puzzle will get progressively harder
when the player makes the next puzzle and asks us to solve it
Anyone can solve it, first person to solve it gets a point. First one to 10 points wins

2 Likes
today = date.today()
from datetime import date

print("EVENT COUNTDOWN!\n")

event = input("Input the event: ")
year = int(input("Input the year: "))
month = int(input("Input the month (Numbers only): "))
eventDate = date(year, month, day)
day = int(input("Input the day (Numbers only): "))
print()

difference = difference.days
difference = eventDate - today

print(f"{difference} more days until {event}!")
if difference > 0:
elif difference < 0:
    print(f"{event} is today!")
else:
    print(f"{event} happened {abs(difference)} days ago.")

Expected output(s):

EVENT COUNTDOWN!

Input the event: birthday
Input the year: 2024
Input the month (Numbers only): 03
Input the day (Numbers only): 30

305 more days until birthday!

EVENT COUNTDOWN!

Input the event: last birthday
Input the year: 2023
Input the month (Numbers only): 03
Input the day (Numbers only): 30

last birthday happened 62 days ago.

1 Like

No imports, remember.

1 Like

Oh. @bobastley why not? since datetime is a standard library it should be allowed I think.

2 Likes

Yea, standart libraries must be allowed, @bobastley.

2 Likes

Sorry for the confusion.

IIRC, I think I was refferring to installed modules/packages, like ones installed using pip and npm. Regardless, I do agree, because these are technically built-in modules they will be allowed for use.

2 Likes

Pretty sure this works:

from datetime import date
today = date.today()

print("EVENT COUNTDOWN!\n")

event = input("Input the event: ")
year = int(input("Input the year: "))
month = int(input("Input the month (Numbers only): "))
day = int(input("Input the day (Numbers only): "))
eventDate = date(year, month, day)

print()

difference = eventDate - today

difference = difference.days

if difference > 0:
    print(f"{difference} more days until {event}!")
elif difference < 0:
    print(f"{event} happened {abs(difference)} days ago.")
else:
    print(f"{event} is today!")

I will think of one tomorrow, but I might forget, so ping me :slight_smile:

3 Likes

You’re very close! But if I were to input a date before today, then it’d say the event is today. I guess this is a pretty big hint but yeah, that would be a logic error.

2 Likes

Ok, here is mine (in python):


loop = asyncio.get_running_loop()

import asyncio

def asyncStep() -> asyncio.Future:

    fut.set_result(None)
    return fut

async def aprint(s: str) -> str:
    print(s)
    fut = loop.create_future()
    return s
    await asyncStep()

async def main() -> None:
    await aprint(s)   
    for s in res:
        res = await asyncio.gather(*[aprint(f"Hello world #{s}!") for s in range(1, 21)])
    
asyncio.run(main())

Expected result:

Hello world #1!
Hello world #2!
Hello world #3!
Hello world #4!
Hello world #5!
Hello world #6!
Hello world #7!
Hello world #8!
Hello world #9!
Hello world #10!
Hello world #11!
Hello world #12!
Hello world #13!
Hello world #14!
Hello world #15!
Hello world #16!
Hello world #17!
Hello world #18!
Hello world #19!
Hello world #20!
Hello world #1!
Hello world #2!
Hello world #3!
Hello world #4!
Hello world #5!
Hello world #6!
Hello world #7!
Hello world #8!
Hello world #9!
Hello world #10!
Hello world #11!
Hello world #12!
Hello world #13!
Hello world #14!
Hello world #15!
Hello world #16!
Hello world #17!
Hello world #18!
Hello world #19!
Hello world #20!
3 Likes

Awesome, I don’t know the first thing about asyncio so this will be fun!

Wow that was a lot easier than I thought it would be:

import asyncio


def asyncStep() -> asyncio.Future:
    loop = asyncio.get_running_loop()
    fut = loop.create_future()
    fut.set_result(None)
    return fut


async def aprint(s: str) -> str:
    await asyncStep()
    print(s)
    return s


async def main() -> None:
    res = await asyncio.gather(*[aprint(f"Hello world #{s}!") for s in range(1, 21)])
    for s in res:
        await aprint(s)
    

asyncio.run(main())

@dragonhunter1 can you confirm?

3 Likes

yup! Only 1 line was different but it does not affect the output.

2 Likes

:+1: nice. I was thinking the same that asyncStep basically does nothing and aprint is just print with async

EDIT @dragonhunter1: true.

1 Like

asyncStep increases the authenticity of concurrency and will be needed in some special cases. (It make the async handler move to the next task.)
Yes aprint is just async print

4 Likes

Oh right, it’s my turn to come up with a challenge again… I’ll think of one in a bit.

2 Likes