結果
| 問題 | No.39 桁の数字を入れ替え | 
| コンテスト | |
| ユーザー |  tanukidon | 
| 提出日時 | 2018-03-24 11:30:44 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 88 ms / 5,000 ms | 
| コード長 | 266 bytes | 
| コンパイル時間 | 44 ms | 
| コンパイル使用メモリ | 7,680 KB | 
| 実行使用メモリ | 12,416 KB | 
| 最終ジャッジ日時 | 2024-06-25 02:44:48 | 
| 合計ジャッジ時間 | 2,533 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
コンパイルメッセージ
Main.rb:11: warning: possibly useless use of != in void context Syntax OK
ソースコード
n = gets.chomp.split("").map(&:to_i)
a = n
b = 0
c = 0
d = 0
m = 0
n.size.times do |i|
  if n[0] == n.max
    n = n.drop(1)
    d += 1
  else n[0] !=n.max
    m = n.rindex(n.max) + d
    c = i
    b += 1
    break
  end
end
a[m],a[c] =a[c],a[m] if b == 1
puts a.join
            
            
            
        