Welcome back to another exciting week of Problem of the Day :)
Since Mondays are all about smiles we're going to make something that checks for them in a string. The goal for today will be to take in a string and return true or false if the parentheses in the string are closed properly (same number of opening and closing () not including smiley faces).
For instance:
#True Today (Monday) is a day all about smiles ( :) ) #False Weirdly formatted (strings (sometimes :) aren't easy :)) to read))
Comments:
Carlos - 11 years ago
It doesn't say that it has to be in order so, i'll take that flaw in the text and use it has an advantage to create a simpler algorithm.
reply permalink
Anonymous - 11 years ago
Balanced parentheses, in C.
reply permalink
btgrant - 11 years ago
Checking for balanced parens in Scala:
reply permalink
Anonymous - 11 years ago
And a short one in J.
reply permalink
Jt - 11 years ago
C#
reply permalink
Pyro - 11 years ago
Python solution with some extra stuff [Number of ( and ) when it fails and code break when ) doesn't have a ( on the left]
reply permalink
Hueho - 11 years ago
Dumb Ruby version:
reply permalink
zifnab06 - 11 years ago
Well, that was fun, although this is slightly messy:
https://zifb.in/0Dnv05XxRJ
reply permalink
Steven Braham - 11 years ago
Very simple python script I wrote:
I know it is way to simple, but I wanted to share it anyway
reply permalink
Karl - 11 years ago
This is my bulky attempt in C# (comments on how to make it better / more efficient would be awesome! :-))
reply permalink