Write a code to for an input arithmetic equation to detect the braces and return the output in Binary i.e. for each opened braces there would be one closed braces. 2+((3-1)/8 ----- Output = False 2+((3-1)/8) -------- Output = True Don't remember the exact wordings of the question.
Sigiloso
a = "2+((3-1)/8" b = a.codepoints.to_a len = b.length countopen = 0 countclose = 0 for i in 0..len-1 if b[i] == 40 countopen = countopen + 1 end if b[i] == 47 countclose = countclose + 1 end end print "#{countopen}" print "#{countclose}" if countopen == countclose print "False" else print "True" end