[Spark Core Puzzle] How to calculate average of list numbers in Spark?(Solution should be scalable!)

Given a list of numbers (could be huge file with integers) , Please provide the solution to calculate the average of those numbers.

P.S: This question is categorized under puzzles so think twice before posting your answer :slight_smile:

val data = sc.parallelize(List.range(0,100))
val sum = data.reduce(+)
val avg = sum.toFloat/data.count()