fn main [ var lines := list_break_to_lines(read_lazy(h[0])); lines := list_flatten(lines); const x := len(lines[0]); const y := len(lines); var ant := array_fill(empty(tuple2(int, int)), [128]); for j := 0 to y do [ for i := 0 to x do [ var c := lines[j][i]; if c <> '.' then ant[c] +<= mktuple2(i, j); ] ] var anodes := array_fill(false, [x, y]); var result := 0; for a := 0 to 128 do [ var b := ant[a]; for i := 0 to len(b) do [ for j := i + 1 to len(b) do [ var x1 := b[i].v1; var y1 := b[i].v2; var x2 := b[j].v1; var y2 := b[j].v2; var xt1 := x1 - (x2 - x1); var yt1 := y1 - (y2 - y1); if xt1 >= 0, xt1 < x, yt1 >= 0, yt1 < y, not anodes[xt1, yt1] then [ anodes[xt1, yt1] := true; result += 1; ] var xt2 := x2 + (x2 - x1); var yt2 := y2 + (y2 - y1); if xt2 >= 0, xt2 < x, yt2 >= 0, yt2 < y, not anodes[xt2, yt2] then [ anodes[xt2, yt2] := true; result += 1; ] ] ] ] write(h[1], ntos(result) + nl); ]