Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created April 14, 2019 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/128e2d98fb8c235e0886fb9fabb012fe to your computer and use it in GitHub Desktop.
Save whatalnk/128e2d98fb8c235e0886fb9fabb012fe to your computer and use it in GitHub Desktop.
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