Wordle comparison: Difference between revisions
→{{header|Raku}}: Changed smart match to string equality; Split `and` where left-side always true.
(→{{header|Raku}}: Changed smart match to string equality; Split `and` where left-side always true.) |
|||
Line 295:
=={{header|Raku}}==
<lang perl6># 20220216 Raku programming solution
sub wordle ($answer,$guess where [==] ($answer,$guess)>>.chars ) {
Line 303:
for %guess -> \trial { # pair
if %answer{trial.key}
@return[trial.key] = 'green';
given trial.key { %answer{$_}:delete
}
}
Line 312:
@return[trial] = 'grey';
for %answer -> \actual { # pair
if %guess{trial}
@return[trial] = 'yellow'
last;
}
}
}
@return;
}
|