プログラミングのお題 ..
346:デフォルトの名無しさん
18/11/10 12:44:51.58 xqriZsUd.net
>>317 Ruby
def indian_poker(a, b, c)
x = [Set[1, 2], Set[1, 5], Set[4, 5]]
winner, winners_num = case
when x.include?(Set[b, c]) then [?A, a]
when a == 3 || (b == 3 && Set[a, b, c] != Set[2, 3, 4]) || x.include?(Set[a, c]) ||
Set[b, c] == Set[2, 4] then [?B, b]
else [?C, c]
end
'%s is %s' % [winner, %w[MIN MID MAX].zip([a, b, c].sort).find{|e| e.last == winners_num}.first]
end
arr = [*(1..5)].permutation(3){|i| puts '%p -> %s' % [i, indian_poker(*i)]};
# =>
[1, 2, 3] -> C is MAX
[1, 2, 4] -> B is MID
[1, 2, 5] -> B is MID
...
以下>>330と同じ
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
1875日前に更新/360 KB
担当:undef