# I am 20,000 days old!! browsing

• posted
0

OK, here are a series of Python brainteasers based on this very special day for me.

Today is NOT my birthday but today is my 20,000th day on the planet. Here the clock has just struck midnight and now it is Sat. 23 Aug 2014. When I run the following Python program:

``````import datetime

def elapsed_datetime(start_datetime, end_datetime = datetime.datetime.now()):
return end_datetime - start_datetime  # returns a datetime.timedelta

start_datetime = datetime.datetime(YYYY, MM, DD)
print(elapsed_datetime(start_datetime))
``````

The result is: `20000 days, 0:03:55.788649`.

Your mission (should you choose to accept it) is to create a Python program that generates a tuple of the following form: ("1999/12/16", "Mon/Tues/Sat/Thurs", 37)

1. The first value in the tuple is the YYYY, MM, and DD of the day that I was born. These values will make the above program respond as it does above.
2. The second value in the tuple is four days of the week for: the day that I was born, my 10,000th day (half my lifetime ago), today (hint:Sat), and my 30,000th day (if I am lucky enough to live that long).
3. The third value in the tuple must be a prime number. It is my first age in years that is prime on or after my 30,000th day (if I am lucky enough to live that long).

`HINT:` Do not worry about the time of day, only worry about the date portion of datetime.

• posted
0

At the first midnight following your birth, it seems that your elapsed_datetime program would have produced (had python been invented yet) 0 days, 0:03:55.788.....

Yet, I think you would say that that new day is the second day on earth, or if counting the number of 24 hour cycles you would say (had you miraculously learned to speak and do math in your first few hours) it was still your first day, but you probably would not say it is the zeroth day! Given you are asking for day of week, it only makes sense if you are using the first convention. If so, you might have said that the second day was day 1, having somehow learned the benefits of zero based indexing before learning how to use the potty.

By extension, the day at which your program reports 20000 days and 3+ minutes would be your 20002nd day, again, assuming that midnight marked the passage of the first day to your second day on earth.

So... when you ask about the 10000th day, I assume you mean the day at which your program would have reported 10000 0:03:55.788....?

• posted
0

But I was born exactly one second BEFORE the stroke of midnight.

1 second != 1 day.

Yes. Go for the day that the program reports 0, 10k, 20k, 30k.

• posted
0

• posted
0

@JonB, Thanks!! Your answer is not 100% accurate but it does have a strange beauty... See my comments on the gist.

• posted
0

Okay,

Here the clock has just struck midnight

Is what threw me. I assumed you really mean JUST, in which case you were born 4 minutes before midnight. Getting the weekday "right" for your birthday was actually a bug.

• posted
0

When writing the problem statement, I should have avoided mentioning time at all. In my solution I used datetime.date only because the way that I was thinking about the problem, the time component did not matter. Thanks again.

Internal error.

Oops! Looks like something went wrong!