Spiral matrix: Difference between revisions
Content added Content deleted
m (→{{header|Factor}}: formatting) |
m (→{{header|Factor}}: grade, not rank!) |
||
Line 1,443: | Line 1,443: | ||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
This is an implementation of Joey Tuttle's method for computing a spiral directly as a list and then reshaping it into a matrix, as described in the [http://rosettacode.org/wiki/Spiral_matrix#J J entry]. To summarize, we construct a list with <code>n*n</code> elements by following some simple rules, then take its cumulative sum, and finally its inverse permutation (or |
This is an implementation of Joey Tuttle's method for computing a spiral directly as a list and then reshaping it into a matrix, as described in the [http://rosettacode.org/wiki/Spiral_matrix#J J entry]. To summarize, we construct a list with <code>n*n</code> elements by following some simple rules, then take its cumulative sum, and finally its inverse permutation (or grade in J parlance). This gives us a list which can be reshaped to the final matrix. |
||
<lang factor>USING: arrays grouping io kernel math math.combinatorics |
<lang factor>USING: arrays grouping io kernel math math.combinatorics |
||
math.ranges math.statistics prettyprint sequences |
math.ranges math.statistics prettyprint sequences |