Advent of Code

Adrian Matoga via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 2 00:45:10 PST 2015


On Wednesday, 2 December 2015 at 03:50:20 UTC, Charles wrote:
(..)
>
>     auto input = "arbitrarily long string of '(' and ')'";
>
>     int floor;
>     foreach(movement; input)
>         floor += (movement == '(' ? 1 : -1);
>
>     writeln(floor);

Speak D to me, please.
	stdin.byLine.front.map!(a => a.predSwitch('(', 1, ')', -1, 
0)).sum.writeln;



More information about the Digitalmars-d mailing list