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; for m := -max(x, y) to max(x, y) + 1 do [ var xt := x1 - m * (x2 - x1); var yt := y1 - m * (y2 - y1); if xt >= 0, xt < x, yt >= 0, yt < y, not anodes[xt, yt] then [ anodes[xt, yt] := true; result += 1; ] ] ] ] ] write(h[1], ntos(result) + nl); ]