sub run-tests() {
use Test;
is sig-start('bvwbjplbgvbhsrlpgdmjqwftvncz', 4), 5, "'bvwbjplbgvbhsrlpgdmjqwftvncz', length 4, start at 5";
is sig-start('nppdvjthqldpwncqszvftbrmjlhg', 4), 6, "'nppdvjthqldpwncqszvftbrmjlhg', length 4, start at 6";
is sig-start('nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg', 4), 10, "'nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg', length 4, start at 10";
is sig-start('zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw', 4), 11, "'zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw', length 4, start at 11";
is sig-start('mjqjpqmgbljsphdztnvjfqwrcgsmlb', 14), 19, "'zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw', length 14, start at 19";
is sig-start('bvwbjplbgvbhsrlpgdmjqwftvncz', 14), 23, "'bvwbjplbgvbhsrlpgdmjqwftvncz', length 14, start at 23";
is sig-start('nppdvjthqldpwncqszvftbrmjlhg', 14), 23, "'nppdvjthqldpwncqszvftbrmjlhg', length 14, start at 23";
is sig-start('nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg', 14), 29, "'nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg', length 14, start at 29";
is sig-start('zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw', 14), 26, "'zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw', length 14, start at 26";
done-testing;
}
sub sig-start(Str:D \str, UInt:D \len --> UInt:D) {
my @S = str.comb;
(^@S).first({ +@S[$_ .. $_+len-1].Set == len }) + len
}
run-tests;
put '';
my \str = $*IN.slurp;
put 'part 1: ', sig-start(str, 4);
put 'part 2: ', sig-start(str, 14);