Python 2.7
To answer the question, one must know the question - and the question is:
What do you get when you multiply six by nine? Thanks to TRiG for the correction
So Deep Thought relies on the handy use of base 13:
613 x 913 = 4213
We import our constants:
from random import randrange as scrabbleBag, randint
from datetime import datetime,timedelta
life,universe,everything,nothing=6,9,1,-3
endOfTheUniverse = 80
We also define our earth-things, being a bag of scrabble tiles, Arthur (a predictable albeit it slightly odd, computer of sorts), Trillian (our rational heroine),
tile = lambda i: scrabbleBag(26)
arthur = lambda i: int(`i`,life+universe+everything+nothing)
trillian = lambda i: ''.join(map(str,divmod(i,life+universe+everything+nothing)))
We introduce Zaphod - a random sort, who eventually runs out of steam as we near the endOfTheUniverse
.
zaphod = lambda : not(randint(0,(endOfTheUniverse-(datetime.now() - start).seconds)**3))
And Marvin the Paranoid Android, whose positive attitude could stop any party:
marvin = lambda : endOfTheUniverse<(datetime.now() - start).seconds
And we continue to run these 4 characters through the mix until they compute it:
while answer is not life * universe * everything:
rack = sum(tile(i) for i in range(7))
answer = (zaphod or marvin) and arthur(rack)
print trillian(answer)
The complete deepthought.py
:
from random import randrange as scrabbleBag, randint
from datetime import datetime,timedelta
life,universe,everything,nothing=6,9,1,-3
endOfTheUniverse = 80
tile = lambda i: scrabbleBag(26)
arthur = lambda i: int(`i`,life+universe+everything+nothing)
trillian = lambda i: ''.join(map(str,divmod(i,life+universe+everything+nothing)))
start = datetime.now()
zaphod = lambda: not(randint(0,(endOfTheUniverse-(datetime.now() - start).seconds)**3))
marvin = lambda: endOfTheUniverse<(datetime.now() - start).seconds
answer = None
while answer is not life * universe * everything:
rack = sum(tile(i) for i in range(7))
answer = (zaphod() or marvin()) and arthur(rack)
print trillian(answer)
This should finish somewhere around the 75 second mark, definitely finishing by 80 seconds. Sometimes earlier to to Zaphods Infinite Improbability Drive.
sleep(75);print("%d\n",41+1);
\$\endgroup\$sleep
available the answers are going to be very hardware dependent I imagine...what takes 75s on your machine will probably take 750s on my machine :P \$\endgroup\$