Skip to content

Instantly share code, notes, and snippets.

@whatalnk whatalnk/abc124-c.rb
Created Apr 14, 2019

Embed
What would you like to do?
AtCoder ABC #124 C - Coloring Colorfully
s = gets.chomp
n = s.length
a = 0
n.times do |i|
if i.even?
if s[i] != "0"
a += 1
end
else
if s[i] != "1"
a += 1
end
end
end
b = 0
n.times do |i|
if i.even?
if s[i] != "1"
b += 1
end
else
if s[i] != "0"
b += 1
end
end
end
puts [a, b].min
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.