aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-161/2colours/raku/ch-2.raku15
1 files changed, 8 insertions, 7 deletions
diff --git a/challenge-161/2colours/raku/ch-2.raku b/challenge-161/2colours/raku/ch-2.raku
index a2c8b1a641..523cc8b95d 100755
--- a/challenge-161/2colours/raku/ch-2.raku
+++ b/challenge-161/2colours/raku/ch-2.raku
@@ -23,13 +23,14 @@ sub MAIN(
@lines .= sort: *.chars;
my @solution;
my $covered-letters = Set.new;
- for @lines -> $current-word {
- if $current-word.comb (-) $covered-letters == 1 {
- @solution.push: $current-word;
- $covered-letters (|)= $current-word.comb;
- last if 'a' .. 'z' ~~ $covered-letters;
+ until 'a' .. 'z' ~~ $covered-letters {
+ with @lines.first(*.comb (-) $covered-letters == 1) {
+ @solution.push: $_;
+ $covered-letters (|)= .comb;
+ }
+ else {
+ die 'No solution available.';
}
}
- die 'No solution available.' unless 'a' .. 'z' ~~ $covered-letters;
@solution.join(' ').say;
-} \ No newline at end of file
+}