Minimum number of cells after, before, above and below NxN squares: Difference between revisions
Minimum number of cells after, before, above and below NxN squares (view source)
Revision as of 18:24, 24 December 2021
, 2 years agoAdded AutoHotkey
Not a robot (talk | contribs) (Add CLU) |
Alpha bravo (talk | contribs) (Added AutoHotkey) |
||
Line 203:
│ │ │ │0 0 0 0 0 0 0 0 0 0│
└───┴─────┴─────────────────┴───────────────────┘</pre>
=={{header|AutoHotkey}}==
<lang AutoHotkey>gridSize := 10
grid := []
loop % gridSize {
row := A_Index
loop % gridSize {
col := A_Index
grid[row, col] := Min(row, col, gridSize+1-row, gridSize+1-col) - 1
}
}
for row, obj in Grid {
for col, v in obj
result .= v " "
result .= "`n"
}
MsgBox % result</lang>
{{out}}
<pre>0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 1 0
0 1 2 2 2 2 2 2 1 0
0 1 2 3 3 3 3 2 1 0
0 1 2 3 4 4 3 2 1 0
0 1 2 3 4 4 3 2 1 0
0 1 2 3 3 3 3 2 1 0
0 1 2 2 2 2 2 2 1 0
0 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 </pre>
=={{header|AWK}}==
<lang AWK>
|