# usage: raku day4.raku [path/to/input] (default: ../data/day4.txt) my $path = @*ARGS[0] // '../data/day4.txt'; my $total = 0; for $path.IO.lines -> $line { my @c = $line.comb; my $n = @c.elems; for 1 .. $n -> $p { my %seen; my $clash = False; for 0 ..^ $n -> $i { my $cell = @c[$i]; next if $cell eq '?'; my $r = $i % $p; $clash = True if %seen{$r}:exists && %seen{$r} ne $cell; %seen{$r} = $cell; } if !$clash { $total += $p; last; } } } say $total;