Problem Statement
A description of the problem can be found on Hackerrank.
Solution
1 2 3 4 5 6 7 8 9 10 |
object FilterPositions extends App { def f(arr: List[Int]): List[Int] = arr match { case x :: y :: l => y :: f(l) case x :: y => y case Nil => Nil } println(f(io.Source.stdin.getLines.toList.map(_.trim).map(_.toInt)).mkString("\n")) } |
Solution also available on my GitHub.