--!name Cryptogram
--!icon puzzle
--!category Puzzles
local aH=[[
C##age)resi#,nce+f#4, mas#$y*f#4, >abs#i*f#4<
Al#Hs#> r#e. T#n#ygratif#^#&$J0astonish%rest<
Man#d$*animal=blushes. Or n#Fs#=<
$xf##;#0#E#j#Qgry, sw#4<
Few /s~h#7er+put up$( #z%annoy#v#J#l example<
Get$/facts first,0]n6c#(d#Cort ]m#.6please<
9re#{*my $4$" #(exaggera{<
Wrinkl#"$<$K5dicate#0e#%smil#"#hZen<
Be c#;l#-5$/dr#- if6must_#~2tidy#Iul<
Let us #Weavor#I+#o=when#1 c#&+die even%$,takXw#DZ#Irry<
I#b resi#*e#j/$L tempta{4
Ex#2i#i#dname e#j ` gives+]ir $@s4
We~#<5%gut#$_s#&*us~look7 at%#,rs4
To #q `#k#d$I*a$'#u rom#v4
9#Kth)r#;ly pure0#f$2e4
Nowa#Os$J #g%pr#M*e#j/#Qd%value*no/4
$.>y#Ug $?+#g e#j/4
9$*#H+get rid#Jtempta{#S yield+it4
Life)far#=o im#{ant2/ ever+talk seri#@ly ab#L4
Ambi{$c#sfailure4
MenZc#& old_#R#fbec#& #l4
We#!d`$GQwe#!said1
Early+bed0#4ly+r#:, #cs2m#(healthy,#1althy,0w#:1
T$3may #~2$B, if two*]m~dead1
Fish0visitors#Zink5 t$3#Os1
He=li#"down$(#>g#`sha#!r#: up$( fleas1
The#%#fwas2#l war,#[2bad peace1
Glas#`china,0reputa{~easily cracked,0#fwe#!m#Wed1
Love$/enemies,$+#Rt#X6y###\ults1
In t#n$$#8/#bZ said#tcert#5,$L $40taxes1
9$*#H+#h2$>#SZ `3
No/ g#)t$" #Vachieved$(#L #3husiasm3
ToZ g#)t#SZ mis$,stood3
A foolish#msi#?ncy#dhobgoblin*$: m#6s3
Adopt%pace*$C: hX$B)pati#i3
What)a#1ed? A#wnt#0ose $8#"#h >yetZ#Ediscove#B3
9rew#7#J/#1#!d`#S #h d`}3
Our$')frit#$ed a#H by detail. Simplify, $2ify8
Ra]rQ#q,Qm`y,Qfame, give me #Kth8
It)#ftoo late+give up ## prejud#Ms8
9mass*m#Elead #os*quiet des#2a{8
Bew#;*a#!en#$pr#:s=requi#%new clo]s8
Not until#1~lo#*do#1Zgin+$,#,nd ##$=8
A h#@e divided ag#5st}#k#b>#,nd$v
Wi#_mal#M#=w#7 n`,$( charity$+#<$v
All%$$'s2#,ge,0#<%men0w#&n$K#wyers(
9c##se*#Ke #q #fdid run smooth(
We #g$)#1 #;_#g >what#1 mayZ(
T$F/ eithX#l#[ bad_$17 mak#"it#I(
Love #<, #Kst2few,#> wrong+n`(
Cow#7s die#ay #ps$7]ir $4s;%valiant #fta#?*$4$# once(
9fool#>#_$1 he)w#:,$#%w#:#a #gs#x#k+be2fool(
BettXt$3h##s#=o#IonQa minute#=o late(
How#\r=$:#bdle th#9s hisZams! So shines2#l d#F52naughty $$(
NeithXa bor#9Xnor2l#WXbe(
Uneasy lies%head=w#4s2c#9n(
If#GsicZ%food*#q,#wy on(
9bettXpart*val##)discre{(
Love looks >with%eyes_with%m#6(
W#:ly0slow; #Rstum#Y=run#\st(
When2man)ti#B*London, he)ti#B*life$m
Patriotism$c#Jsc#Udrel$m
No#a$#2blockhead #Vwrote,$L$+m`y$m
Curiosity)`#s#2man#30cert#5 charac#$#Cics#Jvigor#@ m#6$m
A $: l#4n7#]danger#@ /$g
Fools rush5#0e#%angels f#4+t#)d$g
Hope spr7s e#$nal5$Eb#)st$g
Bl#-ed)h$9expects#8/,$+he sha#!#fb$aed$g
Angels#b fly$H#R$% ]mselv#"l#ely^
9poets #hZ#Emys#$i#@l#^il#3 on%subject*cheese^
There~no unin#$est7 /#`$*unin#$e#?d$J^
An adv#3ure)$*an5conveni#i r#ely#m$&#B^
9travel$esees,%tripp$ehas c#&+see^
H$9can,#>es. H$9cannot, teaches${
T$F #q sincerX#z%#q*food${
Bew#;*false #gledge;})mo#%danger#@Qignor#v${
E#j/)funny,#. #u#.})#ren7+s#&body els#'$W
Ev#Eif6a#%on%r#e track,6#yget run ovXif6ju#*sit ]r#'$W
$.>a member*any#[ganized $S$5y. I am2Democrat.|$W
Genius)` #2c#35spira{0ninety-nine #2c#3 #2spira{$NEdi#/
T$F substitute$+h#7 #+k$NEdi#/
Failure)$2y%op#{unity+begin ag#5, t#n#p more5t#Xig#3ly.|Henry Ford
Speak#Iftly0carry2big#Zick;6#ygo#\r.|$w
Do$)6can,$($)6#h,#0ere6ar#'$w
Doubt)>a pleasant#mdi{_cert#5ty)absurd$Y
If God did >ex#C,} $A nec#-ary+inv#3#x$Y
9j##ney#Jth#@and milesZgins$(2s7le #?p$O
H$9#gs #|)w#:; h$9#gs#x#k)enl#eened$O
Natu#%do#">hurry, yet e#j/)$Xed$O
Thos$9#g#> >$-. Thos$9$-#> >#g$O
To see$))r#e0not+do})want*c##ag#'$Q
9su#2ior#a)modest5 #nspeech_exc#Fs5 #nac{s.|$Q
Real #gledge#S #g%ext#3*`#Aignoranc#'$Q
One sw#<ow#>#">#c2summer$[
Man)by $C2$S#Qimal$[
9$I#dmo#*im#{ant$5#s#+k.|Plato
9unexamined$')>#+#_liv7.|Socrates
While#1~postpon7,$' sp#Fs b$P
As #u#.6#o, #~ $Zliv#'Seneca
Difficulti#"streng]n%m#6,#. labor#>es%bod$P
We suffXmo#%often5 imagina{Qin #)lit$P
Wa#?#8 mo#%#p argu7$)2#l#a $<Z. Be `$t
Very $:)n#Fed+#c2#ry$'$t
9be#*#H*aveng7 thy#k)not+bec#& #}%wrongdoer$t
Men~d#Curbed >by /s_by%views#0i#P#R$%*/s$]
No#a)free#0o)>mas#$*him#k$]
Fir#*say+y###k$)6$A;0]n#>$)6#h+do$]
It#]bad#wn=admits*no modifica{$u
Pract#M#dbest*#<5s#Kctors$u
Read7 #cth2$!#a;#mfer#i2#)dy#a;0writ7 #(exact#a$j
S#& books #;#tta#?d, #|#tsw#<owed,0s#& few#tchewed0dige#?d$j
A w#:#a #y#c mo#%op#{unitiesQhe f#6s$j
Hope#]#l b#)kfast_it#]bad sup#2$j
Vision#dart*see7 /s5visi#Y$o
May6#o #<%#Os*y##$'$o
E#j#a desires+#o #u_no#a $A old$o
H`sty#dfir#*chaptXin%book*wisdom$^
N#Vput off ti#!tomor#9$)6c#(do#=#O$^
$xtenZ#Ne6$-; if #j#Qgry,2hund#B$^
It$"%best*#ps,}$"%#+st*#ps$p
No `)#Tl#-5 t#n$$#0o l#eens%burden*it$+any ` else$p
T$F/5%$$#I irres#Cibly#mtagi#@#. laugh#$0#l hum##$p
T$F charm equal+t#Wern#-*h#4t.$`
I decla#%aftXa#!t$F enjoym#3 #} #)d7!$`
One half#s$$#b>$,#,nd%pleasur#"of%o]r.$`
Why, $MI'veZlieved#.#ay#. six $V /s$7b#)kfast$i
It's#8 #T go7 back+yes#$#O,$HI$"2differ#3 #2#/ ]n$i
Begin at%$I,0go on t#D6c#&#=%#W: ]n#Zop$i
E#j/#Agot2moral, if only6c#(f#6}$i
Take ca#%of%sense,#Qd%s#Uds #y$% c#;*]m$=$i
To travel hope$!y)aZttX/ #z+arrive[
T$F duty#1#I#G#P$,rate#.%duty*be7 #ry[
E#j` liv#"b#^#X7 s#&/[
9$$)so $!#Jnumber*/#`I'm su#%we $< #<Z#. #ry#. k7s[
Know$dapply. W#D$ddo.$}]
No/)#+#_moreQt#n#O.$}]
LaughtXis%sun=driv#"wintXfrom$Efac#'$\
H$9opens2school#>or, closes2pri#/.|$\
Music expr#-es=which#b>be said0on#0ich})$V#tsil#3.|$\
Happy#\milies~a#!a#}; e#j un#ry#\mily)un#ry5}s own #H.|$_
9two $fwarriors~pati#i0tim#'$_
Pati#i:2minor #Nm*despair, disgu#:d#.2$8e@
Bore:2#2#/#0o talks#0en6wish#x+li#?n@
Egot#C:2#2#/*low ta#?, more5#$e#?d5#x#kQin me@
Calamiti#"#;*two k#6s: $U+##$=,0#l #Ntune+#|@
Admira{: ## polite recogni{*ano]r#Aresembl#v+##$=@
Y#4:2#2iod*t$3hund#B0sixty-fiv$am#3s@
Apologize:+lay%f#Uda{ #N2futu#%offense@
Nobody #V#Ngets#0e#%he buried2hatch$k
9safe#*#H+dou#Y$/m`y#S fold} ovXonce0put}5$/pock$k
Con$&r%po#,ge #,mp:}s #Tfuln#-#ms#Cs5%ability+stick+` / ti#!it gets ]r#'Josh B#D7s
Do >$%$'#=o seri#@ly. You #y#fget #L*it a#o$n
A $>)on$9#gs a#!ab#L you0#}s6just$0$n
Positive#Qy/$GQnegative#8/$n
9g#)te#*$@6c#(#c5$'#SZ#mtinu#<y f#476#y#c `$n
A m#&nt's5s#e)$M#+th2life#Aex#2i#i.|OlivXW#We#!Holmes
Time #,ys #u $?$+anyon$9#y#T}$y
Iron rusts$6 dis#T; #,gnant watXlos#"its purity$y
Bl#-ed)h$9has f#Ud #n#+k; let#x#.k#8 othXbl#-edn#-$T
Sil#i)mo#%eloqu#3Q#+ds$T
A#a#0o d#;s+wa#? ` h##*#p has >discove#B%value*lif#'Charl#"Darwin
To $X g#)t /s#1#G#*>$*act_also d#)m; >$*plan_alsoZliev#'Anatole Fr#v
9$B*succ#-)con#,ncy+purpos#'Benjamin Disraeli
Do$s? Very#1#!]n$s, $.large, I#mt#5#Gltitudes.|Walt Whitman
Hope#d/$( fea]rs=#2ches5%soul$r
That} #y#fc#& ag#5)what mak#"life#I sweet$r
Wisdom#dsupreme$5*#rin#-.|Sophocles
Seize%#O, put#8 #Kst5%mor#9.|Horace
They#b$H#R$1 ]y#b.|Virgil
If6#h2g#7en5$/library,#8/ w#DZ lack7.|C#Mro
It)al#Hs darke#*justZ#Ne%#O dawneth$NFuller
He=#os5 hope d#vth$(#L#Gsic$RHerbert
No#a)#(island, #3ire*it#k.|John Donne
9m#6)its own#wce,0in}#k#b #c2heaven*h#X,2h#X*heaven.|John Milton
'TisZt#$+#h #qd0lostQnever+#h #qd at #<.|Alf#B Tenny#/
Ah_a#a#A#)#P$< exc#F #ngrasp,#[$)'s2heav#E#N?|Robert B#9n7
Words #;,*c##se,%$fdrug #Td by#ak#6$h
I #~ six h`#*serv7-men; #Rtaught me a#!I knew$h
You#b >cross%sea by$K #,nd70#,r7 at%wa#$$|
Faith#dbird=feels%l#e#0en%dawn)sti#!dark$|
If t$F s#Kggle, t$F progr#-.|F#Berick Douglass
I attribute m#^ucc#-+this: I #fgave#[#=ok#Qy excus#'Flor#i N#e7ale
No/5$'#SZ f#4ed,})only#t$,stood.|Marie Curie
$.>$D*storms,$+$.$Zsail m#^hip.|Louisa May Alcott
Isn't} n#M+$1=tomor#9#]new #O$(#8 $@s5} yet?|L. M. Montg#&ry
To die w#DZ #(aw$!y big adv#3ur#'$b
Thos$9br7 sunshine5to%#os*#|#b>#~}$6 ]m$=.|$b
T$F/ half#I#G#P#+th#>7#. $2y m#-7 ab#L5 boats.|Kenne#_Grahame
A $:5accuracy $Msav#"tons*explana{.|Saki
I #} #+k:}#\scinat#"me. I#b sit0look at}$+h##s.|Jer#& K. Jer#&
When6#h eliminated%$V,$)#Vrem#5#`how#Vimproba#Y,#GstZ%#Kth$z
It#]capital $@+]orize$7` has data$z
Adapt#[ #2ish,#8w#. ever,)$C's5exora#Y im#2ativ#'H. G. W#Xs
Animals~su#Pagreea#Y $>s: ]y#.k#8 ques{#`#Rpass#8 criticisms$REliot
No/)so p#5ful#=$Em#6#.2g#)t0sudd#Echang#'Mary Sh#Xey
All=we see#[ seem)but2d#)m$(in2d#)m.|Edgar All#(Poe
It$G+fail5#[iginality #z+succ#F5 imita{.|Herm#(Melv#De
A sharp#=ngue#d$*edged#=ol=g#9s keenXwith#m#,nt us#'Wash7ton Irv7
Into each$' s#& r#5#G#*f#<.$~low
Lives*g#)t m#Ea#!rem#6 us#1#b #c ## liv#"sublime.$~low
It$G+offXno exc#TQa bad `$RWash7ton
I $*regret=I #h$# `$'+lose$+my c#Utry.|Nath#(Hale
These #;%#ps=try men#Asouls$NP#5e
9h#7er%conflict,%mo#%glori#@%triumph$NP#5e
No#a #V#?ps5$0 rivXtwic#'Heraclitus
Talk70eloqu#i~not$0:+$-,#Qd+$-#1ll,~two /s.|B#EJon#/
We a#!#h#Zreng#_$?+#Wure%$Us*#|.|$q
Hypocrisy#dhomage#0i#Pv#M pays+$8#'$q
I #h made t#nlettX#uerQusual,$HI lack%#p+#c} short$l
9h#4t has}s #)#/s#0i#P#)#/ #gs#8/ of$l
My$' hasZ#E$!*#$ri#Y $U#`most*whi#P#f#rened.|Michel de Montaigne
9proof#spudd7)in%eat7.|Miguel de Cervantes
Pati#i)bit#$_its fruit)sweet.|Jean-Jacqu#"R#@seau
In%land#sbl#6,%`-eyed#a)k7.|De$&rius Erasmus
9pen)m#eiX#z%s#+d.|Edw#7 Bulwer-Lytton
Beauty)in%eye#sbeholder.|Marg#;t Wolfe Hunger#Nd
If at first6don't succ#F, try, try ag#5.|W#Diam Edw#7 Hick#/
Be >$D*g#97 slowly,Z $D only*#,nd7#Z#D&
$;c#Ut$/chickens$7]y~hatched&
Empty v#-els #c%mo#*no#:&
Abs#i #cs%h#4t g#9 fonder&
You#b lead2horse+wa#$,$#6can't #c} drink&
$;put a#!y## eggs5 ` basket&
When%cat#Aa#H,%m#M #yplay&
A bird5%hand)#+#_two5%bush&
Birds#JfeathXflock#=ge]r&
$;cross%bridge t#D6c#&+it&
Nec#-ity#dmo]r*inven{&
Peopl$9#o5 glass h#@#"$< >th#9#Z`s&
G#)t oaks$6 $: acorns g#9&
A ch#5)$*as#Zrong#.}s#1ake#*link&
9grass)al#Hs greenXon%othX$&#sf#i&
A $>5 n#F#]$>5d#F&
9squeaky#0eel gets%g#)se&
One#a#Ameat)anothXman#Apoi#/&
Fools0]ir m`y~soon$5ed&
Half2loaf$GQno b#)d&
9road+h#X)paved$( #l5ten{s&
$;bite%hand=f#Fs you&
An empt#^ack#b>#,nd upr#e&
It)no #T cry7 ovXspilt milk&
9cob#Yr#Achildr#Ego b#;foot&
What#b'tZ cu#B#GstZ #Wu#B&
Good fenc#"#c #l neighb##s&
$;th#9%baby #L$(%bathwa#$&
You#b't tea#P#(old#>g new tricks&
9apple #ff#<s#\r$6%tree&
N#Vlook2gift horse5%m#Lh&
L#en7 #fstrik#"tw#M5$0#wce&
It#A#(i#!w#6=blows#8body#Qy #l&
Many2#Ke #+d)spoken5 jest&
A leop#7#b>change}s spots&
$;#c2m#Ut#5 #L#Jmoleh#D&
H#6s#e$GQ#Nes#e&]]local a4=[[
 the 
.|Proverb
.|William Shakespeare
 is 
 of 
 to 
thing
 and 
.|Benjamin Franklin
 a 
.|Ralph Waldo Emerson
.|Oscar Wilde
 in
 you 
ing
.|Henry David Thoreau
The 
.|Mark Twain
 that 
not 
.|Ambrose Bierce
 than 
er 
 be
.|Robert Louis Stevenson
the
.|G. K. Chesterton
, but 
one
tion
 it
 are ]]local a5=[[
ll es ourterre omee.|an reast worstaess asson wh weperentearainindard norowiseareall to dosteous's redistillen eed muway so*a truouticefordaych  an]y )touseounevXendellble st or fa)a y sth s,  man canmake is%ightnevXknowhaveenceveryselfgood conhis livetimelovehapp of%+be longance pla himwi#!thanporto]rslikekeepfull was but#+ldtakeside life with whatonly  for underspeakI am  y## %samethinksimplhree death part fromZfo#%virtue who littleDon't shouldselvesfriendenoughmi#,kewouldZsecretnatureafraid%hum#(here)no)betterZcause beginn7 people merely excepts#&tim#".|Thomas .|Lao Tzuy.|SenecaConfucius.|George political$NCarlylemisfortuneimpossibleWi#!Rogersaccomplish.|Voltairel#4n7 how+.|Ar#CotleVictor Hugo.|Epictetus$NJeffersonLeo Tolstoy|Jane Austene disappointJ. M. Barrie#dla#*refuge7)>$?;#1#G#*Xse#"what he mo#*powerful .|AlexandXPope.|Rudy#7 Kipl7.|Lewis Carroll.|Francis Baconet.|Kin Hubbard.|Blaise Pascal.|Samuel Johnson.|Elbert Hubbard.|Jonathan Swift.|Charl#"DickensLa Rochefoucauld.|Emily Dickin#/ I#mtradict my#k.|Marcus Aurelius.|Publilius Syrus.|Abraham LincolnTheodo#%RooseveltWhen angry, count .|Leonardo da Vinci.|Arthur Con#(Doyle.|George Bernard Shaw.|Rabindranath Tagore|Johann Wolfgang von Goe|Henry Wadsworth Longfel]]local a7={0,0,64,36,18,13,7,1,7,7,4,5,2,2,4,7,4,1,2,0,2,0,0,2}local aL,aI="%&()*+/0123456789<=>@QXZ[]^_`{}~","#$"local aq=""for a=33,126 do aq=aq..string.char(a)end local function aU(r)return"["..r:gsub("%p","%%%0").."]"end local a9,a8=aU(aI)..".",aU(aL)local ar={}for bk in(a4.."\n"):gmatch("(.-)\n")do ar[#ar+1]=bk end local function bl(E)local n,W=1,1 for N,v in ipairs(a7)do if E<v then return a5:sub(n+E*W,n+E*W+W-1)end E,n,W=E-v,n+v*W,W+1 end return""end local al local function by(X)return al(bl((aI:find(X:sub(1,1),1,true)-1)*94+aq:find(X:sub(2),1,true)-1))end local function bx(X)return al(ar[aL:find(X,1,true)])end function al(r)return(r:gsub(a9,by):gsub(a8,bx))end local function bt(r,d)local u=1 for N=2,d do u=r:find("\n",u,true)+1 end local au=r:find("\n",u,true)return r:sub(u,(au or 0)-1)end local m=1 for N in aH:gmatch("\n")do m=m+1 end local function a0(d)return al(bt(aH,d)):match("^(.-)|(.*)$")end local t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"local a3="abcdefghijklmnpqrstuvwxyz12345"local M={"QWERTYUIOP","ASDFGHJKL<","ZXCVBNM?!"}local aa,at=16,3 local function bd(d)local aC=d*7919+12345 local q={}for a=1,26 do q[a]=a end for a=26,2,-1 do aC=(aC*1103515245+12345)%2147483648 local E=(aC>>8)%a+1 q[a],q[E]=q[E],q[a]end for a=1,26 do if q[a]==a then local E=a%26+1 q[a],q[E]=q[E],q[a]end end return q end local function bw(ae)local z,H={},""for _ in ae:gmatch("%S+")do if H==""then H=_ elseif#H+1+#_<=aa then H=H.." ".._ else z[#z+1]=H;H=_ end end if H~=""then z[#z+1]=H end return z end local a6=os.time({year=2026,month=1,day=1,hour=12})//86400 local function L()local c=os.time()if not c or c<1700000000 then return nil end local e=os.date("*t",c)return os.time({year=e.year,month=e.month,day=e.day,hour=12})//86400 end local function V(e)return(e-a6)%m+1 end local j={solved=0,perfect=0,streak=0,best=0,last=0,hints=0,psolved=0}local as={"solved","perfect","streak","best","last","hints","psolved"}local K=string.rep(".",m)local p={day=0,g=nil}local G=nil local ad,g=nil,nil local aJ,aG,z,B,q,ac,ao=nil,nil,nil,nil,nil,nil,nil local n,s,y,w,A=1,1,1,false,nil local o,F,x="menu",1,1 local function aY(I)return{idx=I,guess=string.rep(".",26),hints=0,checks=0,at=1,done=false}end local function aT(h)if not h then return""end return table.concat({h.idx,h.guess,h.hints,h.checks,h.at,h.done and 1 or 0},",")end local function Y(r)return math.tointeger(tonumber(r))or 0 end local function aS(r)local l={}for aF in((r or"")..","):gmatch("([^,]*),")do l[#l+1]=aF end local I=Y(l[1])if I<1 or I>m or#l<6 or not l[2]:match("^[%.a-zA-Z]+$")or#l[2]~=26 then return nil end return{idx=I,guess=l[2],hints=Y(l[3]),checks=Y(l[4]),at=math.max(1,Y(l[5])),done=l[6]=="1"}end local function a1()local c={"C1"}for N,d in ipairs(as)do c[#c+1]=j[d]end c[#c+1]=K c[#c+1]=p.day c[#c+1]=aT(p.g)c[#c+1]=aT(G)snail.save(table.concat(c,";"))end local function br()local r=snail.load()if type(r)~="string"or r:sub(1,3)~="C1;"then return end local l={}for aF in(r..";"):gmatch("([^;]*);")do l[#l+1]=aF end for a,d in ipairs(as)do j[d]=Y(l[a+1])end local v=#as+1 local bu=(l[v+1]or""):gsub("[^.osp]",".")K=(bu..string.rep(".",m)):sub(1,m)p.day=Y(l[v+2])p.g=aS(l[v+3])G=aS(l[v+4])end local aK={["."]=0,o=1,s=2,p=3}local function aV(a,b)if aK[b]>aK[K:sub(a,a)]then K=K:sub(1,a-1)..b..K:sub(a+1)end end local function aD()local N,v=K:gsub("[sp]","")return v end local function aE()local e=L()if e and j.last>=e-1 then return j.streak end return 0 end local function D(f)local b=g.guess:sub(f,f)if b=="."then return 0,false end return t:find(b:upper(),1,true),b:match("%u")~=nil end local function Z(f,i,S)local b=i==0 and"."or t:sub(i,i)if i>0 and not S then b=b:lower()end g.guess=g.guess:sub(1,f-1)..b..g.guess:sub(f+1)end local function O()return B[n].x end local function aR()local P,T=0,0 for f=1,26 do if ao[f]then T=T+1 if D(f)>0 then P=P+1 end end end return P,T end local function aA(X,h)ad,g=X,h aJ,aG=a0(h.idx)z=bw(aJ:upper())q,ac,ao,B=bd(h.idx),{},{},{}for a=1,26 do ac[q[a]]=a end for R,an in ipairs(z)do for b=1,#an do local i=t:find(an:sub(b,b),1,true)if i then B[#B+1]={l=R,c=b,x=q[i]}ao[q[i]]=true end end end n=math.min(h.at,#B)w,A,s,y=false,nil,1,1 o="game"aV(h.idx,"o")a1()end local function aB()local e=L()if not e then o="noclock";return end if p.day~=e or not p.g then p.day,p.g=e,aY(V(e))end aA("daily",p.g)end local function a_(I)local e=L()if e and I==V(e)then return aB()end if not(G and G.idx==I)then G=aY(I)end aA("practice",G)end local function bm()g.done=true local aQ=g.hints==0 and g.checks==0 aV(g.idx,aQ and"p"or"s")if ad=="daily"then j.solved=j.solved+1 j.hints=j.hints+g.hints if aQ then j.perfect=j.perfect+1 end j.streak=j.last==p.day-1 and j.streak+1 or 1 j.last=p.day if j.streak>j.best then j.best=j.streak end else j.psolved=j.psolved+1 end A=nil end local function aP()local P,T=aR()if P<T then return end for f=1,26 do if ao[f]and D(f)~=ac[f]then A="All filled in, but something's wrong"return end end bm()end local function aM()for d=1,#B do local a=(n+d-1)%#B+1 if D(B[a].x)==0 then n=a;return end end end local function bb(i)local f=O()local N,S=D(f)if S then A="A hint gave that letter";return false end for U=1,26 do local h,R=D(U)if U~=f and h==i then if R then A=t:sub(i,i).." is already placed by a hint";return false end Z(U,0)end end Z(f,i)return true end local function bo()local f=O()local N,S=D(f)if S then A="That letter is already shown";return end local i=ac[f]for U=1,26 do if U~=f and D(U)==i then Z(U,0)end end Z(f,i,true)g.hints=g.hints+1 A="Revealed: "..t:sub(f,f).." is "..t:sub(i,i)end local function bc()local ag=0 for f=1,26 do local h=D(f)if h>0 and h~=ac[f]then Z(f,0);ag=ag+1 end end g.checks=g.checks+1 if ag==0 then A="Every letter so far is right"else A=ag..(ag==1 and" wrong letter taken out"or" wrong letters taken out")end end local function aX(e)local i=B[n]local av,aN=nil,99 for a,ae in ipairs(B)do if ae.l==i.l+e and math.abs(ae.c-i.c)<aN then av,aN=a,math.abs(ae.c-i.c)end end if av then n=av;return true end return false end local function bs()local e=L()for d=1,m do local a=(g.idx+d-1)%m+1 local b=K:sub(a,a)if b~="s"and b~="p"and not(e and a==V(e))then return a_(a)end end o="menu"end local function ay(J,b)return M[J]:sub(b,b)end local function bn(d)if g.done then if d=="ok"and ad=="practice"then bs()elseif d=="ok"or d=="top"then o,F="menu",1 end return end A=nil if not w then if d=="top"then o,F="menu",1;return end if d=="left"then n=(n-2)%#B+1 elseif d=="right"then n=n%#B+1 elseif d=="up"then aX(-1)elseif d=="down"then if not aX(1)then w=true end elseif d=="ok"then w=true local h=D(O())if h>0 then for J=1,3 do local b=M[J]:find(t:sub(h,h),1,true)if b then s,y=J,b end end end end g.at=n return end if d=="top"then w=false elseif d=="up"then if s==1 then w=false else s=s-1 end elseif d=="down"then s=math.min(3,s+1)elseif d=="left"then y=(y-2)%#M[s]+1 elseif d=="right"then y=y%#M[s]+1 elseif d=="ok"then local k=ay(s,y)if k=="<"then local N,S=D(O())if S then A="A hint gave that letter"else Z(O(),0)end w=false elseif k=="?"then bo();w=false;aP();if not g.done then aM()end elseif k=="!"then bc();w=false elseif bb(t:find(k,1,true))then w=false aP()if not g.done then aM()end end g.at=n a1()end y=math.min(y,#M[s])end local function aW()local c={}local e=L()if e then local az="Today's quotation #"..V(e)if p.day==e and p.g then az=az..(p.g.done and" - solved"or" - carry on")end c[#c+1]={az,"daily"}else c[#c+1]={"Today's quotation: needs the clock","noclock"}end if G and not G.done then c[#c+1]={"Carry on: quotation #"..G.idx,"prac"}end c[#c+1]={"All quotations","list"}c[#c+1]={"Statistics","stats"}c[#c+1]={"How to play","help"}return c end function key(d)if o=="game"then return bn(d)end if o=="menu"then local Q=aW()if d=="up"then F=(F-2)%#Q+1 elseif d=="down"then F=F%#Q+1 elseif d=="ok"then local u=Q[F][2]if u=="daily"then aB()elseif u=="prac"then aA("practice",G)elseif u=="list"then local e=L()x=g and g.idx or(e and V(e))or 1 o="list"else o=u end end return end if o=="list"then if d=="top"then o="menu"elseif d=="up"then x=(x-2)%m+1 elseif d=="down"then x=x%m+1 elseif d=="left"then x=math.max(1,x-10)elseif d=="right"then x=math.min(m,x+10)elseif d=="ok"then a_(x)end return end if d=="top"or d=="ok"then o="menu"end end function touch(bq,u,au)if bq~="board"or o~="game"or not g or g.done then return end local ah=0 for R=1,#z do if R>1 and#z<=5 then ah=ah+1 end ah=ah+2 end local am=au-(ah+1)if am<1 or am>3 then return end local ax=u-at if ax<1 or ax>#M[am]then return end w,s,y=true,am,ax key("ok")end local function ai(a)return a3:sub(a,a)end local function aO()local C,be,ak={},O(),g.done local a=0 for R,an in ipairs(z)do if R>1 and(#z<=5 or ak)then C[#C+1]=string.rep(".",aa)end local ab,aj={},{}for b=1,aa do local k=an:sub(b,b)local i=t:find(k,1,true)if k==""or k==" "then ab[b],aj[b]=".","."elseif i then a=a+1 local f=q[i]local h=D(f)if a==n and not ak then ab[b]=h>0 and ai(h)or"#"else ab[b]=h>0 and"{"..t:sub(h,h).."}"or"o"end aj[b]=f==be and ai(f)or t:sub(f,f)else ab[b],aj[b]=k=="."and ai(30)or k,"."end end C[#C+1]=table.concat(ab)if not ak then C[#C+1]=table.concat(aj)end end if ak then return table.concat(C,"/")end C[#C+1]=string.rep(".",aa)for J=1,3 do local c={string.rep(".",at)}for b=1,#M[J]do local k=ay(J,b)if w and J==s and b==y then local i=t:find(k,1,true)c[#c+1]=ai(i or(("<?!"):find(k,1,true)+26))else c[#c+1]="{"..k.."}"end end c[#c+1]=string.rep(".",aa-at-#M[J])C[#C+1]=table.concat(c)end return table.concat(C,"/")end local function ap(v,_)return v.." ".._..(v==1 and""or"s")end local function bg()local aw,b=g.hints,g.checks if aw==0 and b==0 then snail.status("Solved! No hints, no checks")else local c={}if aw>0 then c[#c+1]=ap(aw,"hint")end if b>0 then c[#c+1]=ap(b,"check")end snail.status("Solved with "..table.concat(c," and "))end snail.board(aO())snail.text("- "..aG)snail.rule()if ad=="daily"then snail.small("Streak: "..ap(aE(),"day")..", best "..j.best..". A new quotation tomorrow.")snail.hint("BACK OK done")else snail.small(aD().." of "..m.." quotations solved.")snail.hint("BACK OK next quotation")end end local function bh()snail.title((ad=="daily"and"Today's quotation #"or"Quotation #")..g.idx)if g.done then return bg()end local P,T=aR()snail.status(A or("Letters "..P.." of "..T.."   Hints "..g.hints))snail.board(aO())if not w then snail.hint("BACK OK keyboard")return end local k=ay(s,y)local bv=k=="<"and"clear letter"or k=="?"and"reveal letter"or k=="!"and"check letters"or t:sub(O(),O()).."="..k snail.hint("BACK quote OK "..bv)end local ba={o=" - started",s=" - solved",p=" - solved, no hints"}local function bi()snail.title("All quotations")local e=L()local bf=e and V(e)local aZ=13 local a2=math.max(1,math.min(x-6,m-aZ+1))for a=a2,math.min(m,a2+aZ-1)do local b=K:sub(a,a)local af=ba[b]or""if a==bf then af=" - today"..af:gsub(" %- ",", ")end if b=="s"or b=="p"then local N,u=a0(a)af=af.." ("..u..")"end snail.row("Quotation "..a..af,a==x)end snail.small(aD().." of "..m.." solved.")snail.hint("BACK back OK play L/R jump 10 UP/DN move")end local function bj()snail.title("Statistics")snail.text("Daily quotations solved: "..j.solved)snail.text("Streak: "..ap(aE(),"day")..", best "..j.best)snail.text("Solved with no hints or checks: "..j.perfect)snail.text("Hints used on daily quotations: "..j.hints)snail.rule()snail.small("Practice quotations solved: "..j.psolved)snail.small("Quotations solved so far: "..aD().." of "..m..".")snail.hint("BACK back OK back")end function draw()if o=="game"then return bh()end if o=="list"then return bi()end if o=="stats"then return bj()end if o=="menu"then snail.title("Cryptogram")local e=L()if e then snail.status(os.date("%A, %B ")..tonumber(os.date("%d")).." - streak "..aE())else snail.status("Every quotation works any time")end local Q=aW()if F>#Q then F=#Q end for a,bp in ipairs(Q)do snail.row(bp[1],a==F)end snail.gap()snail.small(m.." quotations, each in its own letter code.")snail.hint("BACK leave OK choose UP/DN move")return end if o=="help"then snail.title("How to play")snail.text("Each letter of the quotation is swapped for another. The code letters sit under the boxes.")snail.text("The black box is your cursor. Arrows move it; OK opens the keyboard.")snail.text("Pick the real letter: it fills every box with the same code letter.")snail.text("On the keyboard: < clears a letter, ? reveals one, ! takes out wrong letters.")snail.text("No letter stands for itself. The author shows when you solve it.")snail.hint("BACK back OK back")return end snail.title("Today's quotation")snail.text("The daily quotation needs the date.")snail.text("Connect to Wi-Fi once so the clock gets set, then come back.")snail.text("Every quotation can still be played from All quotations.")snail.hint("BACK back OK back")end function start()br()local e=L()if e and not(p.day==e and p.g and p.g.done)then aB()end end
