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と同じ