Let's Play Code Golf

Charles via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 23 14:58:20 PST 2015


> 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


More information about the Digitalmars-d mailing list