Period of first differences by jonathan camacho

for(<>){@a=split;$p=shift@a;@b=map{$r=$_-$p;$p=$_;$r}@a;for(0..25){print($_+1,$/),last if"@b"eq"@{[((@b[0..$_])x500)[0..$#b]]}"}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page