結果
問題 | No.267 トランプソート |
ユーザー |
|
提出日時 | 2016-01-07 05:44:12 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 84 ms / 1,000 ms |
コード長 | 532 bytes |
コンパイル時間 | 56 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-09-19 12:27:15 |
合計ジャッジ時間 | 2,608 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
Syntax OK
ソースコード
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(" ")