Created
April 14, 2019 03:05
-
-
Save whatalnk/128e2d98fb8c235e0886fb9fabb012fe to your computer and use it in GitHub Desktop.
AtCoder ABC #124 C - Coloring Colorfully
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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