Provide functional-programming style solution for 2D Array - DS challenge
There's no need to write a max() method. The Standard Library provides for that.

A for comprehension, with a yield clause, produces a result. So instead of using a mutable var to capture and collect the results of the yield you should capture them directly.

val res = for {...} yield {...}


Or, if you want to process the results more directly, i.e. without the intermediate variable, you can use the somewhat awkward parentheses construct.

def hourglassSum(arr: Array[Array[Int]]): Int = {
  (for {
    x &lt;- 0 to 3
    y &lt;- 0 to 3
  } yield {
    arr(y)(x)   + arr(y)(x+1)   + arr(y)(x+2) +
                  arr(y+1)(x+1) +
    arr(y+2)(x) + arr(y+2)(x+1) + arr(y+2)(x+2)
  }).max
}