import scala.io.StdIn.readLine import scala.util.chaining._ @main def yuki227(): Unit = val f = (hand: List[Int]) => hand match case 3 :: 2 :: _ => "FULL HOUSE" case 3 :: _ => "THREE CARD" case 2 :: 2 :: _ => "TWO PAIR" case 2 :: _ => "ONE PAIR" case _ => "NO HAND" readLine .split("\\s+") .toList .groupBy(identity) .mapValues(_.size) .values .toList .sorted(Ordering[Int].reverse) .pipe(f) .pipe(println)