aboutsummaryrefslogtreecommitdiff
path: root/challenge-155/2colours/raku/ch-2.raku
blob: c650a08816b495b55d21860f670a07304fe88e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env raku

sub pisano-period($n) {
  0, 1, (* + *) % $n ... *
    andthen .rotor(2 => -1)
    andthen [\,] $_
    andthen .toggle: !*.repeated(:with(&[eqv]))
    andthen .tail
    andthen .map(*[0])
}

my @period = pisano-period 3;
say "π(3) = {+@period}\nThe period is: {@period.join: ', '}";