Skip to content

Instantly share code, notes, and snippets.

@j0hn
Created March 9, 2011 18:46
Show Gist options
  • Save j0hn/862716 to your computer and use it in GitHub Desktop.
Save j0hn/862716 to your computer and use it in GitHub Desktop.
#/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
print
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