Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def corrent_format?(str)
- i = 0
- if str.length%2 == 0
- while i < str.length do
- puts "#{get_opp(str[i])} ... #{str[i]} ... #{str[i+1]}"
- if(get_opp(str[i]) && get_opp(str[i]) == str[i+1])
- if(str.length == 2)
- return true
- else
- new_str = str[0..(i-1)] + str[(i+1)..str.length]
- return corrent_format?(new_str)
- end
- else
- return false
- end
- end
- else
- return false
- end
- end
- corrent_format?("[()()]")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement