Created
March 9, 2011 18:46
-
-
Save j0hn/862716 to your computer and use it in GitHub Desktop.
This file contains 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
#/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
import time | |
import random | |
import sys | |
if len(sys.argv) > 1: | |
word = " ".join(sys.argv[1:]) | |
else: | |
word = "Usage: %s [text]" % sys.argv[0] | |
start_time = time.time() | |
stop = False | |
found = [] | |
while not stop: | |
rndstr = "\r" | |
for i in range(len(word)): | |
if i in found: | |
rndstr += word[i] | |
continue | |
rndchar = chr(random.randint(32, 122)) | |
rndstr += rndchar | |
if rndchar == word[i]: | |
found.append(i) | |
print rndstr, | |
time.sleep(0.05) | |
sys.stdout.flush() | |
if len(found) == len(word): | |
stop = True | |
end_time = time.time() | |
#print "Found in %0.2f seconds" % (end_time - start_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment