Minimum number of cells after, before, above and below NxN squares: Difference between revisions

added Arturo
(→‎{{header|AppleScript}}: Added an AppleScript version)
(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}}==
1,532

edits