[2017][ruby][9.x]

sorbet
Alpha Chen 7 years ago
parent 5b874c234e
commit 9c21ad5341

File diff suppressed because one or more lines are too long

@ -0,0 +1,25 @@
require "strscan"
input = ARGF.read.strip
input = input.gsub(/!./, "")
p input.scan(/<[^>]*>/).map {|g| g.size - 2 }.sum
input = input.gsub(/<[^>]*>/, "")
.gsub(?,, "")
ss = StringScanner.new(input)
score = 0
group = 0
until ss.eos?
case
when ss.scan(/\{/)
group += 1
when ss.scan(/\}/)
score += group
group -= 1
else
raise "omg!"
end
end
p score
Loading…
Cancel
Save