#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU s = gets.chomp mx = s.to_i s.size.times do |i| (i + 1).upto(s.size - 1) do |j| t = s.dup t[i, 1] = s[j] t[j, 1] = s[i] mx = [mx, t.to_i].max end end puts mx