Wordle comparison: Difference between revisions

→‎{{header|Raku}}: add another matching color/target
(→‎{{header|Raku}}: add another matching color/target)
Line 383:
 
=={{header|Raku}}==
Updated to add a proof of concept matching for similarity where commonly found on spoofing domain names. Of course this is just the tip of the iceberg (only comparing results after decomposition) and there are way too many [https://util.unicode.org/UnicodeJsps/confusables.jsp Unicode homoglyphs] that can only be matched using a [http://www.unicode.org/Public/security/8.0.0/confusables.txt lookup table/database].
<lang perl6># 20220216 Raku programming solution
 
sub wordle (\answer,\guess where [==] (answer,guess)».chars ) {
 
my ($aSet, $gSet, @return) = (answer,guess)».&{ (set .comb.pairs).SetHash };
 
(my \intersection = $aSet ∩ $gSet).keys».&{ @return[.key] = 'green' }
Line 397 ⟶ 398:
if [eq] (trial,actual)».value {
@return[trial.key] = 'yellow';
$aSet{actual}:delete;
last
}
my @NFD = (trial,actual).map: { .value.NFD }
if [≠] @NFD».elems and [==] @NFD».first {
@return[trial.key] = 'azure';
$aSet{actual}:delete;
last
Line 405 ⟶ 412:
}
 
say .[0]~' vs '~.[1]~"\t"~ wordle .[0],.[1] for (<ALLOW LOLLY>,<ROBIN ALERT>,
<ROBINALLOW SONICLOLLY>, <ROBIN ROBINALERT>, <BULLYROBIN LOLLYSONIC>, <BBAABBBROBIN BBBBBAAROBIN>, <BBAABBBBULLY AABBBAA>);</langLOLLY>,
<ADAPT SÅLÅD>, <Ukraine Ukraíne>, <BBAABBB BBBBBAA>, <BBAABBB AABBBAA> );</lang>
{{out}}
<pre>
Line 414 ⟶ 422:
ROBIN vs ROBIN green green green green green
BULLY vs LOLLY grey grey green green green
ADAPT vs SÅLÅD grey azure grey azure yellow
Ukraine vs Ukraíne green green green green azure green green
BBAABBB vs BBBBBAA green green yellow yellow green yellow yellow
BBAABBB vs AABBBAA yellow yellow yellow yellow green grey grey
350

edits