Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,25 +1,26 @@
|
|||
import std.stdio, std.traits;
|
||||
void main() @safe {
|
||||
import std.stdio, std.traits;
|
||||
|
||||
void main() {
|
||||
enum width = 75, height = 52;
|
||||
enum maxSteps = 12_000;
|
||||
enum Direction { up, right, down, left }
|
||||
enum Color : char { white = '.', black = '#' }
|
||||
uint x = width / 2, y = height / 2;
|
||||
auto M = new Color[][](height, width);
|
||||
auto dir = Direction.up;
|
||||
enum width = 75, height = 52;
|
||||
enum maxSteps = 12_000;
|
||||
enum Direction { up, right, down, left }
|
||||
enum Color : char { white = '.', black = '#' }
|
||||
uint x = width / 2, y = height / 2;
|
||||
Color[width][height] M;
|
||||
auto dir = Direction.up;
|
||||
|
||||
for (int i = 0; i < maxSteps && x < width && y < height; i++) {
|
||||
immutable turn = M[y][x] == Color.black;
|
||||
dir = [EnumMembers!Direction][(dir + (turn ? 1 : -1)) & 3];
|
||||
M[y][x] = (M[y][x] == Color.black) ? Color.white : Color.black;
|
||||
final switch(dir) with (Direction) {
|
||||
case up: y--; break;
|
||||
case right: x--; break;
|
||||
case down: y++; break;
|
||||
case left: x++; break;
|
||||
}
|
||||
}
|
||||
with (Color)
|
||||
for (int i = 0; i < maxSteps && x < width && y < height; i++) {
|
||||
immutable turn = M[y][x] == black;
|
||||
dir = [EnumMembers!Direction][(dir + (turn ? 1 : -1)) & 3];
|
||||
M[y][x] = (M[y][x] == black) ? white : black;
|
||||
final switch(dir) with (Direction) {
|
||||
case up: y--; break;
|
||||
case right: x--; break;
|
||||
case down: y++; break;
|
||||
case left: x++; break;
|
||||
}
|
||||
}
|
||||
|
||||
writefln("%-(%s\n%)", cast(char[][])M);
|
||||
writefln("%(%-(%c%)\n%)", M);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue