In a 9 by 9 grid some points have been marked. The task is it to make a program that counts all distinct squares that can be made using four marked points. Note that squares can also be placed diagonally (any angle).
Input can be one of the following:
- A character string of length 81 containing two distinct characters for marked and unmarked points.
- A one dimensional array (length 81) containing two distinct values.
- A two dimensional array (9 by 9) with containing distinct values.
Output: The number of possible squares
You can write a full program or a function. This is code-golf. I am interested in the shortest code in every language. Standard loopholes are forbidden.
Examples:
Input: ooo......oooooo...oooooo....oo.oo....oooooo...oooooo......ooo.................... Output: 62 Looks like: o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o Input: ...ooo......ooo......ooo...ooo...oooooo.o.oooooo...ooo...ooo......ooo......ooo... Output: 65 Input: ...........o..o..o....................o..o..o....................o..o..o......... Output: 6 Input: ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Output: 540 Input: ...........o..o.......................o.....o....................o...o........... Output: 0