I didn't beat your score, but I did it with ranges (full character count was 174):

stdin.readln();
foreach(x; stdin.byLine)
writefln("%0.15f", map!(a => (a&1?-1:1)/(2.0*a+1))(iota(x.to!int)).sum);

I think if I didn't have to import so many things, I would have done much better :)

-Steve

Yeah, imports were my issue too. Especially with readln, because using that meant I needed std.conv. Why don't reals initialize to zero? That'd save me 4 characters! :P

Reply via email to