annotate bin/rainbow @ 7094:4a2788609dc2

<b_jonas> learn Elendil decided to try to save Numenor from its awful end by navigating to the undying lands and appealing to the Valar, but then he changed his mind, saved his family only and founded a new empire in Middle-earth.
author HackBot
date Sat, 05 Mar 2016 22:07:12 +0000
parents c133bdd56874
children 72e6c7099969
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2475
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
1 #!/usr/bin/env python
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
2 import random
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
3 import re
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
4 w=raw_input()
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
5 p=list('x'*len(w)+'C'*int((341-len(w))/3+1))
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
6 random.shuffle(p)
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
7 p=list(re.sub('C+','C',''.join(p)))
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
8 i=(c for c in w)
c133bdd56874 <shachaf> mv bin/{colourise,rainbow}
HackBot
parents:
diff changeset
9 print ''.join(i.next() if c=='x' else chr(3)+'%02d' % random.randrange(2,15) for c in ['C']+p)