import java.util.Scanner object Problem227 { def proc(cards: Seq[Int]): String = { val sorted = cards.groupBy(x => x).map(x => x._2.size).toList.sorted.reverse if (sorted.size == 1) { return "NO HAND" } (sorted(0), sorted(1)) match { case (3, 2) => "FULL HOUSE" case (3, _) => "THREE CARD" case (2, 2) => "TWO PAIR" case (2, _) => "ONE PAIR" case _ => "NO HAND" } } def main(args: Array[String]) { val sc = new Scanner(System.in) val cards = Seq.fill(5)(sc.nextInt()) val result = proc(cards) println(result) } }