Ramsey's theorem: Difference between revisions

D entry: a little more idiomatic code, removed most constants (a 4 is left)
(→‎{{header|D}}: added D)
(D entry: a little more idiomatic code, removed most constants (a 4 is left))
Line 51:
 
=={{header|D}}==
Another translation of C.
<lang d>import std.stdio;
 
void main() {
enum size_t N = 17;
int[17][17] a;
stringimmutable mark = "01-";
int[17N][17N] amat;
 
forforeach (intimmutable i, =ref 0row; i < 17; i++mat)
a[i]row[i] = 2;
 
forforeach (intimmutable k = 1; k <= 8e; k0 <<=.. 14) {
forforeach (intimmutable i, =ref 0row; i < 17; i++mat) {
intimmutable j = (i + k(2 ^^ e)) % 17N;
a[i]row[j] = amat[j][i] = 1;
}
}
 
forforeach (intconst iref = 0; i < 17row; i++mat) {
forforeach (intimmutable j = 0; j < 17x; j++row)
writef("%c ", mark[a[i][j]x]);
write('\n')writeln;
}
}</lang>