Wordle comparison: Difference between revisions

Content added Content deleted
(Add Tailspin solution)
Line 426: Line 426:
BBAABBB vs BBBBBAA green green yellow yellow green yellow yellow
BBAABBB vs BBBBBAA green green yellow yellow green yellow yellow
BBAABBB vs AABBBAA yellow yellow yellow yellow green grey grey
BBAABBB vs AABBBAA yellow yellow yellow yellow green grey grey
</pre>

=={{header|Tailspin}}==
<lang tailspin>
templates wordle
sink removeFirst
@: $;
@wordle: [$@wordle... -> #];
when <=$@> do ''! @:'';
otherwise $!
end removeFirst
@: [$(1)...];
[$(2)...] -> \[i](
when <=$@wordle($i)> do (green:$)! @wordle($i): '';
otherwise $!
\) -> \[i](
when <'.' ?($@wordle <[<=$>]>)> do (yellow:$)! $ -> !removeFirst
when <'.'> do (grey:$)!
otherwise $!
\) !
end wordle

test 'wordle'
assert ['ALLOW', 'LOLLY'] -> wordle <=[(yellow:'L'), (yellow:'O'), (green:'L'), (grey:'L'), (grey:'Y')]> 'guess LOLLY'
assert ['ALLOW', 'STALL'] -> wordle <=[(grey:'S'), (grey:'T'), (yellow:'A'), (yellow:'L'), (yellow:'L')]> 'guess STALL'
assert ['ALLOW', 'ALLEY'] -> wordle <=[(green:'A'), (green:'L'), (green:'L'), (grey:'E'), (grey:'Y')]> 'guess ALLEY'
assert ['ALLOW', 'ALLOW'] -> wordle <=[(green:'A'), (green:'L'), (green:'L'), (green:'O'), (green:'W')]> 'guess correct'
end 'wordle'

['ALLOW', 'LOLLY'] -> wordle -> !OUT::write
</lang>

{{out}}
<pre>
[yellow=L, yellow=O, green=L, grey=L, grey=Y]
</pre>
</pre>