Created
September 21, 2014 18:11
-
-
Save G33kDude/0ae329940ad5d0dac1bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ascii = | |
( | |
; Necessary newline | |
+----+ | |
| | | |
+-------------------------+-----+----+ | |
| | | | | |
| +-------------------+-----+ | | |
| | | | | | |
| | | | | | |
+-----+-------------------+-----+ | | |
| | | | | |
| | | | | |
+-------------------+-----+ | | |
| | | | |
| | | | |
| | | | |
+-----+----+ | |
| | | |
| | | |
| | | |
+----+ | |
) | |
; Convert text into a grid array | |
Grid := [] | |
for y, Row in StrSplit(Ascii, "`n", "`r") | |
for x, Char in StrSplit(Row) | |
Grid[x, y] := Char | |
; Find corners | |
Corners := [] | |
Horiz := [] | |
Vert := [] | |
for x, Col in Grid | |
{ | |
for y, Char in Col | |
{ | |
if (Grid[x, y] == "+") ; Top left | |
{ | |
Corners.Insert([x, y]) | |
While NextChar := Grid[NextX := x + A_Index, y] | |
if (NextChar == "+") ; Top right corner | |
Horiz[x,y] := [NextX, Horiz[x,y]*] | |
While NextChar := Grid[x, NextY := y + A_Index] | |
if (NextChar == "+") ; Bottom left corner | |
Vert[x,y] := [NextY, Vert[x,y]*] | |
} | |
} | |
} | |
Squares := 0 | |
for Index, Corner in Corners | |
for Index, Right in Horiz[Corner*] | |
for Index, Bottom in Vert[Corner*] | |
if (Grid[Right, Bottom] == "+") | |
Squares++ | |
MsgBox, %Squares% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment