all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,22 @@
int[][] zigZag(in int n) pure nothrow {
static void move(in int n, ref int i, ref int j) pure nothrow {
if (j < n - 1) {
if (i > 0) i--;
j++;
} else
i++;
}
auto a = new int[][](n, n);
int x, y;
foreach (v; 0 .. n ^^ 2) {
a[y][x] = v;
(x + y) % 2 ? move(n, x, y) : move(n, y, x);
}
return a;
}
void main() {
import std.stdio;
writefln("%(%(%2d %)\n%)", zigZag(5));
}