all tasks

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

View file

@ -0,0 +1,12 @@
import std.stdio, std.algorithm, std.string, std.array;
void main() {
enum level = 4;
auto d = ["*"];
foreach (n; 0 .. level) {
const sp = " ".replicate(2 ^^ n);
d = d.map!(a => sp ~ a ~ sp)().array() ~
d.map!(a => a ~ " " ~ a)().array();
}
d.join("\n").writeln();
}

View file

@ -0,0 +1,19 @@
import std.string;
string sierpinski(int n) {
auto parts = ["*"];
auto space = " ";
foreach (i; 0 .. n) {
string[] parts2;
foreach (x; parts)
parts2 ~= space ~ x ~ space;
foreach (x; parts)
parts2 ~= x ~ " " ~ x;
parts = parts2;
space ~= space;
}
return parts.join("\n");
}
pragma(msg, sierpinski(4));
void main() {}