24 game/Solve: Difference between revisions

m
→‎Raku: replace odd syntax in 'roundrobin'
m (Automated syntax highlighting fixup (second round - minor fixes))
m (→‎Raku: replace odd syntax in 'roundrobin')
Line 7,602:
 
# Brute force test the different permutations
(unique @digits.permutations)».join.unique».comb.race.map: -> @p {
for @ops -> @o {
for @formats -> $format {
my $result = .EVAL given my $string = sprintf $format, flat roundrobin(|@p;, |@o, :slip);
my $result = EVAL($string);
say "$string = 24" and last if $result and $result == 24;
}
}
}
 
# Only return unique sub-arrays
sub unique (@array) {
my %h = map { $_.Str => $_ }, @array;
%h.values;
}</syntaxhighlight>
 
{{out}}
<pre>
2,392

edits