--!name Mini Crosswords
--!icon game
--!category Games
local am="!$%&()+,-0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnpqrstuvwxyz|~"local function K(a)return am:sub(a+1,a+1)end local at,ao,aq,ap,ar,an=0,27,54,80,81,82 local t={"much#apronsparesense#reed|Thanks very ___!|Cook's cover-up|Extra tire in the trunk|Sight or smell, for one|Clarinet mouthpiece part|Weight's cousin in physics|___ case (capital letters)|Long-necked bird, or a lifting machine|Rider's mount|Can't do without",
"##was#taxiloserarts#wee##|Used to be|Yellow cab|One who finishes second in a final|Painting and sculpture, broadly|Tiny, in Scotland|It's passed by a parliament|Ripped|Squander|Lumberjacks' tools|A knight's title",
"#man#coralanimereset#yes#|Fellow|Reef builder|Japanese animation style|Set back to zero|Opposite of no|Sedan or hatchback|Cash|Get up|Tom, Dick and Harry, for example|Allow",
"spentallowtabooicon#new##|Used up|Permit|Off-limits|Little picture you tap on a screen|Fresh|Smooth, glossy fabric|Location|Arm joint|Midday|A pair",
"#alsodrawnroyalemerywarm#|Too|Like curtains at night|Fit for a king|___ board (nail file)|Not quite hot|Tied the game|Pleasant smell from a bakery|Cake tier|Big buzzing group of bees|Sole",
"last#ethosstakesiren#cent|Final|Guiding beliefs of a group|Vampire slayer's weapon|Ambulance's wail|Penny|Not as much|Space under the roof|Split with others|Arcade coin|Mailed",
"##not#havesevenpear#all##|Negative word|Own|Days in a week|Fruit shaped like a light bulb|Every one|Place for a massage|Back of the foot|Of the navy|Finished|Number of fingers",
"##can#caregorgealoudsales|Is able to|Worry (about)|Deep, narrow valley|Not silently|Store discount events|Petrol, in the US|Fizzy brown drink|Christmas song|Disagree loudly|Requires",
"#madesaladicinggracenose#|Created|Caesar or Greek dish|Cake topping|Elegance|Pinocchio's giveaway|Write your name on|The big picture, or a close-up lens|Assumed name|Tango or waltz|Brink",
"see##ever#tired#lily##eye|Spot|At any time|Ready for bed|Easter flower|Organ of sight|Group of matching things|Wicked|Spooky|Depend (on)|Hair color product",
"#beencraveratesovertpony#|Has ___ there before|Long for|Prices per hour|Out in the open|Small horse|Harvest|Well done!|Consumed|Each|Bird's home",
"did##atom#denim#mono##rim|Performed|Tiny building block of matter|Jeans fabric|Not stereo|Basketball hoop's edge|Pop|Thing on a list|Blood giver|Small car, or a small crossword|Mother",
"##one#granhabitalivemater|Single|Grandma, informally|Routine, or a nun's outfit|Living|Alma ___|Over-the-top actor|Fancy party|The moon's path|Too trusting|Go in",
"#thenshaveleveramendbent#|Next|Use a razor|Crowbar, for one|Change, as a law|Not straight|Thick flat piece of stone|Party motif|Safe place|Happening|Geek",
"#mustlanceindexagentrare#|Have to|Jousting knight's weapon|Back-of-book list|Spy, or a star's rep|Barely cooked, as steak|Fibber|Japanese comics|Below|Part of a play|Phone message",
"had##oven#pivot#dine##lee|Owned|Baker's appliance|Turn on a central point|Eat dinner|Sheltered side, at sea|Bunny's move|Keen|Red villain with a pitchfork|Not any|Golfer's peg",
"pattyagreesainttied#end##|Burger disk|Say yes|Halo wearer|Like a game at 2-2|Finish|Copy and ___|Once more|Attempted|Look after, as a garden|So far",
"#may#panicangerdolly#red#|Month after April|Sudden fear|Rage|Camera cart, or a toy|Stop light color|Writing ___|Country estate house|Ninety degrees, for one|Give way|Shed tears",
"##off#freealgaegear#own##|Not on|No charge|Pond scum|Bike part you shift|Possess|In the past|Went by plane|Heart or liver|Dread|Charge",
"##get#mayocameoarms#tea##|Receive|Sandwich spread, for short|Brief film appearance|Limbs|Earl Grey, for one|Purring pet|Female horse|Greek letter after beta|They're blue, green or brown|Also",
"##put#hopefalsealienroots|Place|Wish|Not true|E.T., for one|A plant's underground part|Distant|Angel's ring|Disease Jonas Salk fought|Unhappy|Ages 13 to 19",
"#day#sonicangerdolly#red#|Twenty-four hours|Relating to sound|Rage|Camera cart, or a toy|Stop light color|Down in the dumps|Blood giver|Ninety degrees, for one|Give way|Shed tears",
"dramaradaradorewipe#not##|Stage play genre|Plane-spotting system that reads the same backwards|Love to bits|Clean with a cloth|Negative word|Like curtains at night|It has stations but no trains|Take on as your own|Female horse|We ___ the champions",
"#can#sugarprimaalley#yes#|Is able to|Sweetener in tea|___ donna|Narrow back street|Opposite of no|Place for a massage|Like a pig's tail|Nimble|Tom, Dick and Harry, for example|Beam of sunlight",
"##two#profalertceaseeaten|A pair|College lecturer, for short|On the lookout|Come to an end|Consumed|Top playing card|Desperate request|Trick or ___|Not as good|Many times",
"##but#casetakenaged#bed##|However|Suitcase, or a detective's job|Not free, as a seat|Grown old|Place to sleep|Browser page, or a bar bill|Hamster's home|Cooked in an oven|Second-hand|Number of fingers",
"was##over#widow#dale##net|Used to be|Finished|Woman whose husband has died|Valley, in northern England|Fishing ___|Cry of amazement|Keen|Four-door car|Part in a play|Soaked",
"#lastfancyinnerscenetext#|Final|Elaborate, or to take a liking to|On the inside|Part of a play|Phone message|Clenched hand|Jousting knight's weapon|Extra building added on|Perfume|Wheel's rubber, in Britain",
"##say#ratedeltaoasistract|Speak|Speed, or price per hour|Triangle-shaped river mouth|Desert water spot|Large stretch of land|Full stop|Back end|Spicy dip, or a Latin dance|Space under the roof|It makes bread rise",
"#top#focalunclereuse#dry#|Peak|___ point (centre of attention)|Parent's brother|Use again|Not wet|Cat's coat|Fit and firm, as muscles|Happen|Bell's ___ (facial condition)|Sheltered side, at sea",
"strawtribeeagleache#let##|Drinking tube|Clan|Bird of prey, or two under par in golf|Dull pain|Allow|Take without asking|Copy through thin paper|Correct|Capable|Tiny, in Scotland"}local as={"QWERTYUIOP<"," ASDFGHJKL?","  ZXCVBNM  "}local k=0 local v,g,p,l={},{},{},{}local e,n,x=1,"A","grid"local w,D=1,1 local I,s="list",1 local j,u={},{}local Q,r=nil,1 local function A(a)return v[a]~="#"end local function Y(d)k,r=d,d local m=t[d]local U={}for b in m:sub(27):gmatch("[^|]+")do U[#U+1]=b end for a=1,25 do v[a]=m:sub(a,a);p[a]={}end l={}for ai=1,2 do local q=ai==1 and"A"or"D"for G=0,4 do local F={}for S=0,5 do local a=S<=4 and(ai==1 and G*5+S+1 or S*5+G+1)if a and A(a)then F[#F+1]=a else if#F>=2 then l[#l+1]={cells=F,dir=q}for M,b in ipairs(F)do p[b][q]=#l end end F={}end end end end local X,af=0,{}for a=1,25 do local G,q=p[a].A,p[a].D if A(a)and((G and l[G].cells[1]==a)or(q and l[q].cells[1]==a))then X=X+1 af[a]=X end end for c,h in ipairs(l)do h.num,h.clue=af[h.cells[1]],U[c]or""end local o=u[d]or""for a=1,25 do local b=o:sub(a,a)g[a]=(A(a)and b:match("%l"))and b or""if j[d]and A(a)then g[a]=v[a]end end e,n=l[1].cells[1],l[1].dir x,Q="grid",nil w,D=1,1 I="play"end local function Z()if k>0 and not j[k]then local i={}for a=1,25 do i[a]=g[a]~=""and g[a]or"-"end u[k]=table.concat(i)end local ab={}for d=1,#t do ab[d]=j[d]and"1"or"0"end local i={"M1",r,table.concat(ab)}for d,o in pairs(u)do if not j[d]and o:find("%l")then i[#i+1]=d.."="..o end end snail.save(table.concat(i,";"))end local function aA()local m=snail.load()if type(m)~="string"or m:sub(1,3)~="M1;"then return end local o={}for aG in m:gmatch("[^;]+")do o[#o+1]=aG end r=math.max(1,math.min(#t,tonumber(o[2])or 1))for d=1,#t do j[d]=(o[3]or""):sub(d,d)=="1"end for c=4,#o do local d,ay=o[c]:match("^(%d+)=(.+)$")if d then u[tonumber(d)]=ay end end end local function ae(ac)for c=1,#t do local d=(ac-1+c)%#t+1 if not j[d]then return d end end return ac end local function J()return l[p[e][n]]end local function ak(B)for c,b in ipairs(B)do if b==e then return c end end return 1 end local function _()local h=J()local B,E=h.cells,ak(h.cells)for c=E+1,#B do if g[B[c]]==""then e=B[c];return end end local aC=p[e][n]for aD=1,#l do local m=l[(aC-1+aD)%#l+1]for M,b in ipairs(m.cells)do if g[b]==""then e,n=b,m.dir;return end end end if E<#B then e=B[E+1]end end local function av()local V,H=0,0 for a=1,25 do if A(a)then if g[a]==""then V=V+1 elseif g[a]~=v[a]then H=H+1 end end end if V>0 then return end if H==0 then j[k]=true u[k]=nil x="grid"else Q=H==1 and"Full, but one letter is wrong"or("Full, but "..H.." letters are wrong")end end local function aE(a,aw,ax)local y,b=(a-1)//5,(a-1)%5 repeat y,b=y+ax,b+aw if y<0 or y>4 or b<0 or b>4 then return nil end until A(y*5+b+1)return y*5+b+1 end local function O(f,C)return as[C]:sub(f,f)end local function aB()local b=O(w,D)if b=="<"then if g[e]~=""then g[e]=""else local h=J()local E=ak(h.cells)if E>1 then e=h.cells[E-1];g[e]=""end end elseif b=="?"then if g[e]==v[e]then for M,T in ipairs(J().cells)do if g[T]~=v[T]then e=T;break end end end if g[e]==v[e]then for a=1,25 do if A(a)and g[a]~=v[a]then e=a if not p[a][n]then n=n=="A"and"D"or"A"end break end end end g[e]=v[e]_()else g[e]=b:lower()_()end av()Z()end local L={left=-1,right=1,up=0,down=0}local R={left=0,right=0,up=-1,down=1}function key(c)if I=="list"then if c=="up"then s=(s-2)%#t+1 elseif c=="down"then s=s%#t+1 elseif c=="ok"then Y(s)end return end Q=nil if j[k]then if c=="top"then I,s="list",k;Z()elseif c=="ok"then Y(ae(k))end return end if x=="type"then if c=="top"then x="grid"elseif c=="ok"then aB()elseif c=="left"or c=="right"then local f=w repeat f=(f-1+L[c])%11+1 until O(f,D)~=" "w=f elseif R[c]then local C=(D-1+R[c])%3+1 for ag=0,10 do for M,f in ipairs({w-ag,w+ag})do if f>=1 and f<=11 and O(f,C)~=" "then w,D=f,C;return end end end end return end if c=="top"then Z()I,s="list",k elseif c=="ok"then x="type"elseif L[c]then local q=L[c]~=0 and"A"or"D"if q~=n and p[e][q]then n=q;return end local d=aE(e,L[c],R[c])if d then e=d if not p[e][n]then n=q end end end end local function az(a,N)if not A(a)then return"#"end local P=g[a]local ad=P~=""and P:byte()-96 or 0 if not j[k]then if a==e then return K(ao+ad)end if N[a]then return K(at+ad)end end return P~=""and("{"..P:upper().."}")or"o"end local function au()local N={}for M,b in ipairs(J().cells)do N[b]=true end local z={}for y=0,4 do local i={"..."}for b=1,5 do i[#i+1]=az(y*5+b,N)end i[#i+1]="..."z[#z+1]=table.concat(i)end if j[k]then return table.concat(z,"/")end z[#z+1]="..........."for C=1,3 do local i={}for f=1,11 do local b=O(f,C)local W=x=="type"and f==w and C==D if b==" "then i[f]="."elseif b=="<"then i[f]=K(W and ap or an)elseif b=="?"then i[f]=W and K(ar)or"{?}"else i[f]=W and K(aq+b:byte()-65)or("{"..b.."}")end end z[#z+1]=table.concat(i)end return table.concat(z,"/")end local function aa(h)return h.num..(h.dir=="A"and" Across: "or" Down: ")..h.clue end function draw()if I=="list"then snail.title("Mini Crosswords")local d,aj=#t,13 local al=math.max(1,math.min(s-6,d-aj+1))for a=al,math.min(d,al+aj-1)do local aF=j[a]and" - solved"or(u[a]and u[a]:find("%l")and" - started"or"")snail.row("Puzzle "..a..aF,a==s)end local m=0 for a=1,d do if j[a]then m=m+1 end end snail.small(m.." of "..d.." solved.")snail.hint("BACK leave OK open UP/DN move")return end snail.title("Mini Crossword "..k)local h=J()if j[k]then snail.status("Solved! Well done.")snail.text("Every word is right.")else snail.status(Q or(x=="type"and"Typing"or"Grid").." - "..h.num..(h.dir=="A"and" Across"or" Down"))snail.text(aa(h))local ah=p[e][h.dir=="A"and"D"or"A"]if ah then snail.small(aa(l[ah]))end end snail.board(au())if j[k]then snail.hint("BACK puzzles OK next puzzle")elseif x=="type"then snail.hint("BACK grid OK press L/R move UP/DN move")else snail.hint("BACK puzzles OK type L/R move UP/DN move")end end function start()aA()s=j[r]and ae(r)or r if not j[r]and u[r]and u[r]:find("%l")then Y(r)end end
