Created
January 11, 2015 22:50
-
-
Save vslaykovsky-zz/aa5a1b6f65579b8a7829 to your computer and use it in GitHub Desktop.
tweak.rb
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
gets.to_i.times do |i| | |
m = [] | |
c = gets.chomp | |
if c == "0" | |
puts "Case #{i+1}: 0 0" | |
else | |
c.size.times do |i1| | |
c.size.times do |i2| | |
c[i1],c[i2] = c[i2],c[i1] | |
m << c.clone | |
c[i1],c[i2] = c[i2],c[i1] | |
end | |
end | |
m = m.sort.select{|v| v[0] != '0'} | |
puts "Case #{i+1}: #{m.first} #{m.last}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment