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 13:31, 8 March 2023
, 1 year agoadded Arturo
(→{{header|AppleScript}}: Added an AppleScript version) |
Drkameleon (talk | contribs) (added Arturo) |
||
Line 584:
</pre>
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">printMinCells: function [n][
cells: array.of:n 0
loop 0..dec n 'r [
loop 0..dec n 'c ->
cells\[c]: min @[dec n-r, r, c, dec n-c]
print cells
]
]
loop [10 9 2 1] 'n [
print ["Minimum number of cells after, before, above and below" n "x" n "square:"]
printMinCells n
print ""
]</syntaxhighlight>
{{out}}
<pre>Minimum number of cells after, before, above and below 10 x 10 square:
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
Minimum number of cells after, before, above and below 9 x 9 square:
0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 0
0 1 2 2 2 2 2 1 0
0 1 2 3 3 3 2 1 0
0 1 2 3 4 3 2 1 0
0 1 2 3 3 3 2 1 0
0 1 2 2 2 2 2 1 0
0 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0
Minimum number of cells after, before, above and below 2 x 2 square:
0 0
0 0
Minimum number of cells after, before, above and below 1 x 1 square:
0</pre>
=={{header|AutoHotkey}}==
|