On Wednesday, 9 December 2015 at 02:48:31 UTC, Sean Campbell wrote:
how is this D speek. it's far shorter and easier to read if you use
writefln("floor %s",input.count('(') - input.count(')'));

Yes, I don't find chaining of methods all that easy to read either, but you can do less work by taking advantage of D already knowing the length of the input:

import std.stdio;
import std.algorithm;

void main(){
        immutable input = "(((())";
        immutable long len = input.length - 2*input.count(')');
        writeln(len);
}

Reply via email to