結果

問題 No.2920 Blood Type
ユーザー ducktail
提出日時 2024-10-13 13:55:51
言語 Ruby
(3.4.1)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-10-13 13:55:56
合計ジャッジ時間 4,531 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

module BloodType
  def solve(s, t)
    a = {:A => 0, :B => 0, :AB => 0, :O => 0}
    (0..1).each do |i|
      (0..1).each do |j|
        a[child_blood_type(s[i], t[j])] += 1
      end
    end
    a.values.map{_1 * 25}
  end

  def child_blood_type(p1, p2)
    case [p1, p2]
    when ["A", "A"]
      :A
    when ["A", "B"]
      :AB
    when ["A", "O"]
      :A
    when ["B", "A"]
      :AB
    when ["B", "B"]
      :B
    when ["B", "O"]
      :B
    when ["O", "A"]
      :A
    when ["O", "B"]
      :B
    when ["O", "O"]
      :O
    end
  end

  module_function :solve, :child_blood_type
end

s = gets.chomp
t = gets.chomp
  
puts  BloodType.solve(s, t).join(" ")
0