fork download
  1. object Main extends App {
  2. val result = Iterator.single(readInt())
  3. .flatMap(count ⇒ Iterator.continually(readInt()).take(count))
  4. .foldLeft(0)((i, max)if (i > max && i % 5 == 0) i else max)
  5. println(s"Sosnooley: $result")
  6. }
Success #stdin #stdout 0.37s 322368KB
stdin
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
stdout
Sosnooley: 15