On 08/25/2011 04:24 AM, Timon Gehr wrote:
On 08/25/2011 04:11 AM, bearophile wrote:
Timon Geh:
Done: http://pastebin.com/Vx4hXvaT
Theoretically it could use std.bigint, but I have still not found out
how to convert these to string without pain.
To compute Hamming(1_000_000) this converts a BigInt to string:
string bigIntRepr(BigInt i) {
const(char)[] result;
i.toString((const(char)[] s) { result = s; }, "d");
return to!string(result);
}
Bye,
bearophile
Ah, it is the format string that is not standard as well, now I get it.
I'll give it a try tomorrow, thanks!
http://pastebin.com/C6vf9DQQ
It delivers correct results, but it takes 20min to run. (probably mainly
GC-related, I don't know)