Last active
August 29, 2015 14:18
-
-
Save colinvh/0936bdf0b04830914f64 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 | |
from __future__ import print_function | |
import random | |
def main(): | |
return ''.join((chr(c + 97) for c in generate())) | |
def generate(): | |
text = decompose(markov(data, sigma)) | |
while True: | |
sig, r = row(text[-2], text[-1]) | |
if sig > 0: | |
text.append(markov(r, sig)) | |
else: | |
return text | |
def markov(dat, sig): | |
i = -1 | |
s = 0 | |
target = random.randint(1, sig) | |
while s < target: | |
i += 1 | |
s += dat[i] | |
return i | |
def decompose(num): | |
i, rem = divmod(num, 26 * 26) | |
j, k = divmod(rem, 26) | |
return [i, j, k] | |
def row(i, j): | |
index = 26 * i + j | |
sig = rows[index] | |
index *= 26 | |
return sig, data[index:index + 26] | |
data = map(lambda c: ord(c) - 32, (u'" # ! !!! #" E9"%F "N! ' | |
u'\u0150 "Q 88 3 . :!`"\x8b !~c \xcd-%!C!-@#\x927 M C\'#K\x94&#(k.!09#' | |
u'L#!C4!*9) 2 " "! !# * "# ,& " % .R" # "% "\' %!G! ! >! !\xd6' | |
u' J%> \')JS# 8# 5 # # , 4 # %$"- " ! " *:"!* "!"w-\xb0 " }>7 #' | |
u'! $ # $ + !!\x82! !/ # %! # !" # ( n4BM\x9c58%' | |
u'\x8d <\u010d?#U7 \'0e=:% :"fY!!\x82# !d #F"Ke #.#, " . \x92&\xbc\u0187' | |
u'\x87(\xb2,\xad"Y$ y]!$!\x9c\u01db=&!#<) ! #! #""" =# ![! v' | |
u'9 !.!!E~ )6>( ) . \x9c`\x85\u0109\x93,O%\xdc#]W' | |
u'dBN9&~P\xdd%6%!\xcc"3#@ g !qQ 6#3"3B$ \xb8\xf3, ! 1!R#I"\u037f$ \xb0' | |
u'\u0180 %.&#\xb0 \\-\x8aY!% (% %7C%%F! !#A$7 $!CTX ! \' !C !\x8c Q ! ' | |
u' 3 #! & >* $#&""" *-$/# &#% " # $ 6 ! \'" !! # # +(!%0%!' | |
u'"" *\'$-! #%\'# % * !6 * \' "" $+ 1j+!"3$( *d\'i!\' \x8eVW' | |
u')!#!,!\' 0 * 8 ) "# " . " ! " " " ' | |
u'# ! # S!.B2+0\') !u%P"""\xe7DI $%!&" " ' | |
u' ! % ! B(65(#)! #!R\'M0$"=6[$$ ' | |
u'# & ! Y \u0227 C O' | |
u' @! # ! $ ! ! " " ^\'$5#")#(' | |
u'!!N(_Z" W/4N&1*3 ! ! \x8e' | |
u' m \x84 n < * & 0 \' , ;" ! #! $ ! #' | |
u' #50#%. ,!"T\'4" !\x88LV #!% # " ! ' | |
u' ! # !" $ # &(# " " ' | |
u' !O1A!#$%\'!#\x98H\x98![!\xcb\\\xb634! % ! ' | |
u' !! 7 6 %- - : \' ; ! ! ! ( 7&$1&' | |
u'&!"- R,\x8d\'K l_6! $ "!" ! " " $! ! ' | |
u' \xc5*"#\xd0$#!\xad :40\x86! _(*L - 4 l/(A80# F%MR< =Fg&( ' | |
u' 10"#z$!\'4!!M((,) #@&& - 6 \x7f t R V B ' | |
u' # ! " " ! " ! $ ! ! A0H6.*+,)!!\x85' | |
u'\xfa\u01c58X"\xa1EHv69$$"! ! ! - ' | |
u' \x85 \x90 k x !I 9 # !" !" L ," ' | |
u'\x91 " ~ N J ! # #,"&&& ( \x86J*)/ hSI! ' | |
u' %!4 ! # ""$ #' | |
u'") " # \'0\'!"-&2 #V7[ * ?&H(-# @#) \' # ' | |
u' " ( ! ( " % " " # " ( > #3 F $ $ ! 0 BEr.1' | |
u'I+$%" x^\xca.H$\xd7\x83G&40&!"& & " % " $ $ i " !!! ' | |
u'! " ! # ( ) $ * \x84*\x88,A:?!! !66aY/ 4\xaaU4?!& !$ ' | |
u' " $ \' ! " ) o , \' ! ' | |
u' # - # 5 + ! \' ) # ! & !%5*!# >FV1' | |
u'\' G+*>%V%!#& ! !# ! \' ! # j O ' | |
u'U p 6 ( ! # * )% !#* 0( ?! " # ! &! " *\'' | |
u'T"%#$ " !A./%+!3/(! !# - \' " 3 * 3 ( " ' | |
u' " $"!"#!" ! !$$, (! ! ' | |
u' ! GB\x8e ,-# RdFg -!\x95p\x90<3\' !@% ? ( & < @"#= $ A ' | |
u')"S GQ O: [ C"\xeeJ " =\'!0M%6#x ()$8" ;($; \' - "$-_!&!$* 37-b!J K' | |
u')B!$& (. !"DA 6 / 8 .!-C % P! D!/"F \'$$: F 3 $ . 8 & ' | |
u'! 2 $ $ # ( %-"!J !!"-\'[!! *96 \' "$ $ # # "! !&' | |
u' $ !! "# ! l\'&Y\xa33\'#\x9d $\u010e6!P/ $;:13" \' wU! t \x86' | |
u' #((X` $ 3 ! ( n1d\xbf\xa0(C.\x80""$%VY#")\x9f\u0290A*( +0 (* &\'!" 7' | |
u'*F 0 .&$I#"" !:!! ; @M 5! C) C*a- " # [ \xf9Yb6' | |
u'\xdeIf-\xe8#.H\xa6\x95\x91J"\x9b\xc7\xa77Z6!\x9b!1\'j&Z!#9r #&1%BT\' \xfe' | |
u'\u01362"! & n#3 \xa1$ }\x89 !#""R! i%\x911 $ @$ $\'&! $ "#1$ / N42 "! ' | |
u' = \x99 X : "! "" #!A$#$0" %8 ###7" #/$ ! " = K 4 .5 /n!' | |
u' h, !" \'#!$9" " !$&$$! "# !$ ! ) ! $ ! !! "#!*G%"!!#2 "' | |
u'C*; D-2* "#$!" ! ! ! ! ! ' | |
u' " 2%8&, " & !9&2" \x921/$"" ! *" S "M 5$ - )\' \' ' | |
u' ( ! " " ! ))Z2J\'+ ="U ' | |
u' HI2 " * # ! " ` R 5 ' | |
u' \\ J / & ! # %!("!' | |
u' \' & B!(@" \xc5% 9!"\'! ! ' | |
u' ` b C C + # ! " " ! !! " !!! 3 #! ! # ' | |
u' !) $ ( $"! ) " \x97\'8 <?& " ! ' | |
u' ' | |
u' 4%+#"+#- d8\\!% _7d/(% "%$ ! # % ' | |
u' " ! # 7#"$,!!#$ @(\xad' | |
u'G$ \x80=A!!$ % ! # ! # ( 4 !\\ 8 #! &$ , 2$!!,' | |
u'"!!" !$ #,! !#\xb9" # ! 750&\'") 8\'\x871! *:3#* !! ' | |
u' " " Q i 9 F - 1 7 , ! ' | |
u' !# ! :! < 4 :" !\' &$#0&!*!% 6!Q4# B,70\'% ! ! ' | |
u' # " " \xf8 \x81 K R .' | |
u' # "" "" !! "! 2 ! " (# 1 ! <!! Q!! I :/8" ' | |
u' .6& #! % " ! ! ! ' | |
u' ! \'# & % " ":/4&' | |
u'(6#? +zb\xcb#9 \xae>Q4+4 -($ # ! " , " $ ! ! ! " ! ' | |
u' " ! " $ \x9b%6AE%# ; wav1\'!\u0157YJ++.(+"" ' | |
u' # " * ! ! # ! " ! 6' | |
u'6X/7&3 !!i4o1I DUG#+ & ! ! ! ' | |
u' % + ( 6 ! ! ! 5 / & ! \' " ! # ( ) !# ' | |
u' $ " -2-91%- \'!$\x85^^L= \xa2MAq(< &"# " ! ! ! ' | |
u' ! 4 7 H ! h - # # ! "! # % ' | |
u' # "!5)!\'% !$#$! "\'!! # & #-\'&#%,! \'E: # E8/ ""! ! ' | |
u' 1 % "% ) %!!G! # ! ' | |
u'-) 9 )=) ! A4(! 1%! "\xc94\u0106 # >-{ !!"' | |
u' !+3 F 6 \xa3!"* 4! 7 " \xc1 # \x91 ^\x91 \xae/ $N ,%UJ \' S" ' | |
u'?\u0108 > N! %!(*! !*%+ \' ) !1&!0+! !T$f ! b2R\'1& "\' ?M ; ) !* ' | |
u' " 8* g P I >\xb3> $/Y4! 7#!/ ! ""! " # ! ' | |
u'" # " ! " ! & 1 # ! # !" ! \\*' | |
u'&D\x8a&%\'z -\u011d. 8! !*?&&% * l: ~! !U !F!>\xa5 !( 1 " \xf4,\xaf' | |
u'\xc8\u01acs\u01d3:~(K)&Lf#*"\xab\xedCN$$/!""4*! ) <,\u027c ( 9-8\xab#"' | |
u'# !4% :" 00! A& -G %3<% ! ! D I"G8\x8a\') 3 +48!' | |
u'8( G+?#%( * C%g$\x8e$"\xddX!-,}%WA#&u\u012f$!! ( \xa8!B!\xd8% m\xbe !$&%f' | |
u'! ?"\x89h ! \xae3 ! !\x99! !3 Y \u0144 E , ! # ' | |
u' " # " ! ! "!! # $ )! ! ! ' | |
u' ) - \' !! 0 "@!! ##" #!(1 " %" "#"!!" ' | |
u' $ 8!!#' | |
u' ! " " &" +)% & ' | |
u' ! !$ "$# $ ! ' | |
u' ' | |
u' $"& # #,* !& % **!-$" \' ' | |
u' ' | |
u' ## 3 ( """(%8 ! /)% ! " ' | |
u' ' | |
u' # &!"("!!!)$-"# ' | |
u'2$1"!"!%"# # " + ! ! " !! ! # ! ' | |
u' " ! $# \'<##"! 4%W## [2X"!$ ; ! ! ! # # ' | |
u' ! ! ) " ! ( ! ! %"#)/!! !**w"$ +/- "" "' | |
u' ! ! !! / N - # ! ' | |
u' " - " % + * 8 ( !!"#"$ "! !#!\'!"' | |
u' &"!\'$%" " $ $ % * # # ' | |
u' & % " ""! ! !)% ! $ (# +$ ! ! # "# % " " ' | |
u' ! %!! ( "!! ! ! ) $ !" \' ' | |
u' " ! ! ! $ " "! ! # ' | |
u' !NtK#"N)T *#`\u0112$7!\xbd|\xf2M57)J+, 1 # " - $ $ " ) ' | |
u'& ,$ !! 3 " !\' " "#" I$ !0 !"#-! ()"# % # ~9kLD-W):!!)W\x9966 mt' | |
u'\x93,=.>k!)! $!!!, ! \' (!"( ! 0 , * & & \' & "' | |
u' \' rA\xac:KEi !&+N\u010eRH-%z\x9f,D # \' ! ' | |
u' \' $ #) " !" # # ( \xa0,"$\xc9\'"$\xb8! \' \x84" !*"I ' | |
u'\' U ; "+ ") ! - $ # # " ! # 77a/\'$\xa4#@ "' | |
u'\'=eRD+jAUb0p!,!+ #! 5% ! & #!$ ! " !' | |
u' % " & \'! 0 (7 ! ! 4# !7 ! " 6! 7 .B " 7 )# (!! 2' | |
u'%%1:2?%- %"$(d?/% 5dX $ - !3 !N ) # ( " !" ) ' | |
u' ! "$,"""#\'" !#-+"+ "?/! $ " ! ' | |
u' *[B# Y\'?#9\x88&\u0166"$ \xb0Q\xe0*"#+.\'?! !L @ ? !;! @!' | |
u' 5 #!1&"")#% )##$"! " ! ! >&(M#".!$ !S3' | |
u'\u013b*$ \x9dG\xa0 ")#$! # # " $ $ ' | |
u' # $ ! 3 }V("3 !"l)\xe2$ !5\x80\x8d* % ! ' | |
u' ! # & # H ' | |
u'N A @ 1 , , $ * # ! ! $*-<$!.#+ &O*\xc80# \x8bH' | |
u'MX(!!!"T# g!!:2 $g R I)K3 \' " " ' | |
u' # ! !"!%! "# ! " (" !*! " ! ! ! ! \'+&#&' | |
u' " "W+="! 2U> # " " " ! ! ' | |
u' + % ! ! "\' \'\'$ ' | |
u' "8A7&#>&4 )\x93=["? ~<\xbf3*% !%% ! 4 ! $ \' $! * 9 \xde' | |
u' wS !2 ^ 0 D5 ( k+$!\xc2&#\'\x86!!6*"Y)"N>$E + 4 B,D,=10$. M049(&xp' | |
u't@,E2M#/ > F 7 : * 3 6( #\x92& /2 #S% 4" 88<F " ) 2 0 & ' | |
u' / " # z)\xb4.A;C$! %,9L:5\'$w~=+ $ $" # $ - & ' | |
u'! 6$!!* ," !! ""# ) ) ( % % ! ( % " \' ' | |
u' G j T ! 7 ! . ! 9 $25*$$/ + >\\B++ p@OT28\'"" ! ! $ &' | |
u' " 6 # ! ! & & # & :$7"i1#,' | |
u'\x80 %(- \\9 !#oG$$ % \xaf!!!\xcf""`\xf1 -#!a! \x92# @ " 5!,&0&+#& % !/C' | |
u')&# )9?! !/ K 4 1 $ ! , # "$ & ! ' | |
u'" ! %#!! ! \'. $!!!#!!!"! * % % ! ! % ! ' | |
u'4> "%" ))(2 $!S-L!! " 18""<" !@$ 3 !0 %:#(#! " R < F O: \xa1. A 9 B' | |
u'4 ( 1##/[#-$O !-"!6# (+ 5 ( C &!\' # !& !*#-! !*/&"\' #! \' $_ * $' | |
u'! & ! /$ ! B" !L!6#/! +#+\' p!"2 ! s * ( & !%)% " ! #!,U!!' | |
u'" !; S +G( ! ! % ! " %"! P !\' !$ #! % # ! & ' | |
u'g$&s\x8f(%#\x99 .\x9c0!\xa4& !28K0" N!yR! \xce% !l "`\'X\x9d!!$ $ " 6 ' | |
u'\xa1#`r\xd5Tv#\x9c*+\'#Nk!&*\x8b\xb5(F)!V% "$| 6$! dJJL 3 55d # "<!" g' | |
u' "r@!#0!!M= 1.5* " 3 . \x9a:?\x80\xaa\'B"\xaf ](u' | |
u'l][!ZN\xf3+$) \x94!?$8 \x8b #2\x86 "\')!2J" _\x9f%!" ( M\'+ `"!x_ *#!J$ ' | |
u'1\'_) # + #+1-##^!& @!\xa9 +!v\u01dd\x87 \' ! ": \x8d ; ! \' ' | |
u' " 2."-P& (( !<\'s!( %-"" ! $!"!# %!!#: !! ! !! . /!$&#! ! # !$' | |
u'! !"! " ) \' #! (F+! 2 1 "R%i!7!\xd0R\x852%\'!*"# ' | |
u' # ! & "! # ! # ! ! " ' | |
u' S!^B3$( #!"O"\x8c$* \u01446R#!(""$ ! " ! ! # " ' | |
u' " X "x l # !\x81 -!#% o 5 j9A!3 &;#j,+"E;Y#" " "! ' | |
u' ! " \' \xb6 \x99 [ A ' | |
u' = + & " " ! $ # "!3*,"\' ? ' | |
u',\x8f.W71 \x81\x9eT4#-#" 0 P !4 @! 9 @# ! 0 ' | |
u' G \xc6 \x88 \u0131 , ! $!# 1 %6 !!" - .& ! C 0 ! ) ' | |
u' #\x8b A # 3 $ !($(#&$ ! !I(6 ) G2< ! ! ' | |
u' # " ! ! !" # ! !# ! 4 ' | |
u'# ! ! ' | |
u' ! ' | |
u' ' | |
u' ' | |
u' ' | |
u' ' | |
u' ' | |
u' \x8e \x84 \xa0 - ' | |
u' # ' | |
u' h\xa2\x7f(C' | |
u'i.u#*\x99\x7f\u0159"\x97!:b\u01353M<"<-@ : C $ L #! ) % 2 " O v' | |
u'9 #+ - !"\'F $ 6%! :! $J $ "1! %)$# $ \' \xc6:\x8a\x83\x92TW49$$\\e' | |
u'\xaf4h(+\u0121\x97.XB\'7"+ /! ) \' ( $ , : _ %9 +! 2 "" -' | |
u' + + 3 % 2 " # \xd6V\xf2woFa! !&Qa\xc6r]! \xb7\xad=L!&!* ' | |
u' # # " $" !3 #) &#"%# !*" ! & 8" $< D .! "!" ' | |
u'! ( \x81!" =" #a " G! !!* ! % U% R$ #= ! & 0! )%\' " $ NHoH26X$@%*lz' | |
u'\xc7t\x9f".\x9fj\x9fJ_1/#* 5 A* %! 9 ,((% ! * ' | |
u' U | %u O . \\ :"""t! 0L $"#!K,! @.!" " G"" ]%#\x85\x83 ' | |
u' +\'#@ 1,!; " 8\'%5>?/&, 2 *NI!< #s6 !!! !? E < % ! " / ' | |
u' & , / ! %##%# ! *+$,0 )$ " ' | |
u' " ! ! ! "L70!*5$0!\'p1y!* D*K6*-%\' ) $ " & ' | |
u'" 2 # q a !nE %! x | H # + ! " " " F.O2A\'(#+ !' | |
u'_G\x85%<.s<I,3//3!# \' % \' & ! " " " %! " ' | |
u'\x81)! o# k !$0#q" ; !4!& 1 WXLp</F "RHn\xb4\'!\'\x83y)l ( # ' | |
u' ! ) 8 C " # ! % 7 J C = ! = - " Y >' | |
u' ? 9 . " 5 , , 3 $& " &$:,&*$!(! ca\xde(5 g +B&#' | |
u' #!_! \x94 Ir 8 e B! 0 # T $ ! ! "' | |
u' ! # R#" m# $\xb7 %+!J" $ $1 - 3 \u0122&$!\u0143)!+\u0110! 9,"\xed' | |
u'& \u011f# Z"\' D .F1&\'+& + GCE!J g>$ $ % & ! E ' | |
u' ? < 5 " " "@!! ! !23> " )%! ' | |
u' ! ! ! jL(#)M(d /\xa2D\xd5!7 \xa06\xd9-+)-$ \' $ ' | |
u' $ & # # % \x90 " % ! ! ! # ! ' | |
u' T)=Eb)1&0 "aQ\xd924 \u026c]7)))0! & ! % ! & ! 8 $ " ' | |
u' " ! ! d&!%\u0132(!"^ !)-#z$!]("? 0 Q \x83C\u01760CMB #ck\xd7' | |
u'\u01c3<)2kx)\xa0 " " ! $ ! 2' | |
u' \x86 % " # " # 9 ( # + # # ) % " ' | |
u'$! %&B+(\': . )Fa\u010e:X \u015f30D#D\'#"" ! ! " # % ' | |
u' \u015b \x82 \u0116 \xe9 d ! ` """!*" ' | |
u'#$ ! - )# (%"% # L \xba!!"U !M A *( $! 9 I.)I(%$ * 3>=-* \xbfC6 ' | |
u' !! # " . , !7 / " ! ' | |
u' "!" ! ! ." B .# "! ! % ! " !! !! !! $\'5 !%!$ %' | |
u'S": ! P)E "$ # (2 !4 "2" 7% "! */(\'" ! * . 7 ?= W0 \' )!O% " 1! 8' | |
u'c 2 G $ ( !* " " \'!&) !%%$! ! 5!A!! 36/" #&! Z !! ! #! ' | |
u' 3! 5 Bp# $""& !! + # ! #"..& ! @ ?!( 3L' | |
u'`!$ " #! " ! # ! !, # ! ! " \xa8$++N.\' C ' | |
u'*c%"70 !8i0#! %!6T#!S% !@ "<+(P! (!&" 5&i\xa39%N"W A$"-$" "/r! " % ' | |
u' ! # " # " 0#%= " $$!"?!!.* !-! (8 --8" " " $ ' | |
u' k;51\xb5(\\!b"+1+W</!SKK)/# <!?%="\x89 !U` 1# !(,! B\x93& $ M!.!e !W' | |
u'm (##Q -\'S+ " &" # ( % # " ' | |
u' ! $ " ! ! %$ ! ! " !! ' | |
u' " $ # ! , )4(! ."(!#e"Y ! ?2D% ' | |
u' ! &"%$$#&$% !O$' | |
u'\x98#! \u012fN8 !%* ' | |
u' E$A75"( " #K O2 0a>%0 " ! ' | |
u' ! " ! ' | |
u' 7 # ) %P"&! *$)*!# & ' | |
u' % " ' | |
u' ! - "" ' | |
u' ! ! ! ' | |
u' ! ! ! !$\'( #,#2 (U%4 $' | |
u' \x84;W!)!$g!& \' ! * # ! # ! ! ! % ' | |
u' ! $ # ! # >%!)A "!3 S + " D5\' " " ! # # $ # ' | |
u' " 2 O T 3 ! ! .2%%/ H"s " (FO $' | |
u' ! " " ! ! ! # ) % ! ' | |
u' !! # ( % ! !!!&!!"# " !*$! " # ! #! #*' | |
u'1(V! \x99!!#"! ! ! ! ! % ! \' ' | |
u' , 9 * & !! " !! !"" %# !!$! " ! ! ! #! # ! ' | |
u' ! !!! ! " ! ! ' | |
u' " % !!$! ' | |
u' ! %! !# $&& #& ! ! # + #' | |
u'\' \' # % \' \'! " ! "&) &!! !' | |
u' " ! ! \' $ $ ' | |
u' " (",($"" "+$( )" !! ' | |
u' " ! ' | |
u' ! # !!* ! &!% ( ; % 2 , \' # ' | |
u' ! ! ' | |
u' &! 6 !\' \' ? ) ! $! " # ! & ! ' | |
u' " " ! " &' | |
u' " %% !! "+#=!$!4!# # $ $\' ' | |
u' " ) # # $ 2 ?$ 3 , $! , " "! E +' | |
u'# !!!! ! -!&"! 3\'& !! ! ! # " $ !" " !#!( # !' | |
u' " $ * ! !! ) " " ! ' | |
u' # ! ! / 6 - !3 +! " #& 2$! 4 % ' | |
u' #\'+4 " ! . +#, #!" #+ & "! "" $& %"!2 $ ($%1!! !" 8' | |
u' 1% " "5 %\'0# ! ! / "&! 5 "= " !$ !' | |
u' #!# , !F !" $# &G" " 0 0* , " ! # #! "! ! ! " ' | |
u' ! $ * ! # "$ % # ! ' | |
u' " ! !#" %!! ' | |
u'!$!+ ! 3 ! ! ! ' | |
u' %!"!! ! !\' , -##! ! ' | |
u' ! !!" \' % %$&!! "!' | |
u'!! 0 ' | |
u'" " ! # "" ! ' | |
u'\' #*%" % !! ! ! ' | |
u' ! ! " ' | |
u' ! ! ! $ ! ! ! ! ' | |
u' ! $ # \' ! \' ' | |
u'1 " ! % ')) | |
rows = [0] * (26 * 26) | |
for i, d in enumerate(data): | |
rows[i/26] += d | |
sigma = sum(rows) | |
if __name__ == '__main__': | |
print(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment