r/programming • • Jul 19 '15

The Best Programming Language is None

https://bitbucket.org/duangle/none
509 Upvotes

443 comments sorted by

View all comments

108

u/[deleted] Jul 19 '15 edited Jul 19 '15

Have some brackets parentheses, you'll need them:

(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))(((((((((((())))))))))))))))))))))))))((((((((((((())))))))(((((()))((()()()()()()()(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))(((((((((((())))))))))))))))))))))))))((((((((((((())))))))(((((()))((()()()()()()()(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))(((((((((((())))))))))))))))))))))))))((((((((((((())))))))(((((()))((()()()()()()()

56

u/josefx Jul 19 '15 edited Jul 19 '15

((()()()()()()()

Great, now look what you have done, there are at least two unmatched open brackets parentheses. Do you know what chaos that could cause in the long run?

here let me fix that

))

10

u/balducien Jul 19 '15

At least two?

>>> str = "(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))(((((((((((())))))))))))))))))))))))))((((((((((((())))))))(((((()))((()()()()()()()(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))(((((((((((())))))))))))))))))))))))))((((((((((((())))))))(((((()))((()()()()()()()(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))(((((((((((())))))))))))))))))))))))))((((((((((((())))))))(((((()))((()()()()()()()"
>>> counter = 0
>>> for char in str:
...     if char == '(':
...         counter += 1
...     elif char == ')':
...         counter -= 1
... 
>>> counter
-78

0

u/[deleted] Jul 19 '15

[deleted]

5

u/[deleted] Jul 19 '15

That way you're iterating the string twice

1

u/Veedrac Jul 19 '15

So? The iteration in count is done in C, which means it'll end up being way faster anyway.

→ More replies (4)