Skip to content

Instantly share code, notes, and snippets.

@ninoseki
Created March 14, 2015 21:08
Show Gist options
  • Save ninoseki/5b81903b941580200717 to your computer and use it in GitHub Desktop.
Save ninoseki/5b81903b941580200717 to your computer and use it in GitHub Desktop.
Codeforces#291 Div2-A
# http://codeforces.com/contest/514/problem/A
digits = gets.chomp.chars.map(&:to_i)
inverted = digits.map.with_index do |n, idx|
case idx
when 0
(9 - n) < n && n != 9 ? 9 - n : n
else
(9 - n) < n ? 9 - n : n
end
end
puts inverted.join.to_i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment