Anonymous user
Zig-zag matrix: Difference between revisions
→{{header|Scala}}
m (→{{header|REXX}}: added a comment to the REXX section header.) |
|||
Line 4,564:
Uses the array indices sort solution used by others here.
<lang scala>def zigzag(n:
(0 until n*n) foreach {i =>
val lSorted = l.sortWith {
if ((x+y) % 2 == 0) x<u else y<v ▼
var a = new Array[Array[int]](n,n)▼
}
lSorted.zipWithIndex foreach {
}
a
}</lang>▼
▲ sort{case ((x,y),(u,v)) => if (x+y == u+v)
}
zigzag(8).foreach{
ar => ar.foreach(x => print("%3d".format(x)))
println
▲}</lang>
=={{header|Seed7}}==
|