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 - 10 years, 8 months 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 - 10 years, 8 months ago
Balanced parentheses, in C.
reply permalink
btgrant - 10 years, 8 months ago
Checking for balanced parens in Scala:
reply permalink
Anonymous - 10 years, 8 months ago
And a short one in J.
reply permalink
Jt - 10 years, 8 months ago
C#
reply permalink
Pyro - 10 years, 8 months 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 - 10 years, 8 months ago
Dumb Ruby version:
reply permalink
zifnab06 - 10 years, 8 months ago
Well, that was fun, although this is slightly messy:
https://zifb.in/0Dnv05XxRJ
reply permalink
Steven Braham - 10 years, 8 months ago
Very simple python script I wrote:
I know it is way to simple, but I wanted to share it anyway
reply permalink
Karl - 10 years, 8 months ago
This is my bulky attempt in C# (comments on how to make it better / more efficient would be awesome! :-))
reply permalink