SHARE
TWEET

Untitled

a guest Apr 24th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. s = gets.chomp
  2. n = s.length
  3. a = 0
  4. n.times do |i|
  5.   if i.even?
  6.     if s[i] != "0"
  7.       a += 1
  8.     end
  9.   else
  10.     if s[i] != "1"
  11.       a += 1
  12.     end
  13.   end
  14. end
  15.  
  16. b = 0
  17. n.times do |i|
  18.   if i.even?
  19.     if s[i] != "1"
  20.       b += 1
  21.     end
  22.   else
  23.     if s[i] != "0"
  24.       b += 1
  25.     end
  26.   end
  27. end
  28.  
  29. puts [a, b].min
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top