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} ~~eq trial.value {
@return[trial.key] = 'green';
given trial.key { %answer{$_}:delete and; %guess{$_}:delete }
}
}
Line 312:
@return[trial] = 'grey';
for %answer -> \actual { # pair
if %guess{trial} ~~eq actual.value {
@return[trial] = 'yellow' and %answer{actual.key}:delete;
last%answer{actual.key}:delete;
last;
}
}
}
@return;
}
 
256

edits