Created
June 28, 2017 21:18
-
-
Save iamukasa/16ac728cdc01fabaf8d6cc13f67661a6 to your computer and use it in GitHub Desktop.
Program to solve the problem set: A monkey is randomly hitting keys in a keyboard,how long does it take it to type a word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys,random,time | |
alpha=('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','s','t','u','v','w','x','y','z') | |
words="" | |
starttime =time.time() | |
#monkey iterator | |
while str(sys.argv[1]) not in words : | |
a=random.choice(alpha) | |
words+=a | |
print words | |
endtime =time.time() | |
print 'The monkey took',endtime- starttime,'seconds' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A US President is randomly hitting keys to type a tweet. How long does he take to type covfefe