annotate bin/rainbow @ 6628:8fa17e1ae537

<izabera> ` printf \'FNR == 1{ for (i = max; i >= 1; i--) print a[i] } { a[max=FNR] = $0 } END { for (i = max; i >= 1; i--) print a[i] }\' > bin/tac; chmod +x bin/tac
author HackBot
date Sat, 30 Jan 2016 21:25:52 +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)