Minimum number of cells after, before, above and below NxN squares

From Rosetta Code
Revision as of 05:37, 2 August 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task:Find and show on this page the minimum number of cells after, before, above and below '''NxN''' squares, where '''N = 10''' <br><br> =={{header|Ring}}=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Minimum number of cells after, before, above and below NxN squares is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task
Find and show on this page the minimum number of cells after, before, above and below NxN squares, where N = 10



Ring

<lang ring> see "working..." + nl see "Minimum number of cells after, before, above and below NxN squares:" + nl row = 0 cellsMin = []

for n = 1 to 10

   for m = 1 to 10
       cells = []
       add(cells,m-1)
       add(cells,10-m)
       add(cells,n-1)
       add(cells,10-n)
       min = min(cells)
       add(cellsMin,min)
   next

next

ind = 100 for n = 1 to ind

   row++
   see "" + cellsMin[n] + " "
   if row%10 = 0
      see nl
   ok

next

see "done..." + nl </lang>

Output:
working...
Minimum number of cells after, before, above and below NxN squares:
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 
done...