Quick actions

cmd+k|ctrl+k

Navigation

Languages

PWC #236, Task 2

Snippet info

Language

Raku

Visibility

public

Author

seaker

Created

2023-09-26T03:09:40.591739Z

Updated

2023-09-26T03:09:40.591739Z

# URL: https://theweeklychallenge.org/blog/perl-weekly-challenge-236/#TASK2

my @ints = $*IN.words;
my %remain is SetHash = |@ints;
my @loops;

while %remain {
    my @cache;
    my $i = %remain.keys.min;

    repeat {
        $i = @ints[$i];
        @cache.grep($i) ?? last() !! @cache.push($i);
    } while True;

    @loops.push(@cache);
    %remain.unset($_) for @cache;
}

put +@loops;
INFO