結果

問題 No.267 トランプソート
ユーザー code-devocode-devo
提出日時 2016-01-07 05:44:12
言語 Ruby
(3.3.0)
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 532 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 16,040 KB
最終ジャッジ日時 2023-10-19 16:21:17
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
16,036 KB
testcase_01 AC 87 ms
16,040 KB
testcase_02 AC 83 ms
16,040 KB
testcase_03 AC 83 ms
16,040 KB
testcase_04 AC 84 ms
16,040 KB
testcase_05 AC 84 ms
16,040 KB
testcase_06 AC 89 ms
16,040 KB
testcase_07 AC 83 ms
16,040 KB
testcase_08 AC 84 ms
16,040 KB
testcase_09 AC 84 ms
16,040 KB
testcase_10 AC 84 ms
16,040 KB
testcase_11 AC 83 ms
16,040 KB
testcase_12 AC 84 ms
16,040 KB
testcase_13 AC 83 ms
16,040 KB
testcase_14 AC 83 ms
16,040 KB
testcase_15 AC 83 ms
16,040 KB
testcase_16 AC 82 ms
16,040 KB
testcase_17 AC 83 ms
16,040 KB
testcase_18 AC 83 ms
16,040 KB
testcase_19 AC 83 ms
16,040 KB
testcase_20 AC 83 ms
16,040 KB
testcase_21 AC 86 ms
16,040 KB
testcase_22 AC 85 ms
16,040 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Card
  attr_reader :suit, :num
  
  def initialize(str)
    @str = str
    @suit = case str[0]
      when "D" then 1
      when "C" then 2
      when "H" then 3
      when "S" then 4
    end
    @num = case str[1]
      when "A" then 1
      when "T" then 10
      when "J" then 11
      when "Q" then 12
      when "K" then 13
      else str[1].to_i
    end
  end
  
  def <=>(other)
    [suit, num] <=> [other.suit, other.num]
  end
  
  def to_s
    @str
  end
end

gets
puts gets.split.map{|s| Card.new(s)}.sort.join(" ")
0