Goatball point spread

Challenge
No

Goatball is a popular sport on Vuohen saari. There are only two teams, the Typerä and the Vakava, but there's nothing else going on, so it's popular. Cthulhu wants to know about goatball point spreads.

Point spread is the difference between scores in a game. So if:

  • The New York Nannies scored 10 points and the Buffalo Billies scored 7, the spread would be 3 for the game.
  • The Brisbane Bed Bugs scored 11 points and the Yosemite Yolks scores 16, the spread would be 5.
  • The average of the spreads for the games would be (3+5)/2 = 4.

Download the data set. Here's part of it:

  • "Typera","Vakava"
  • 6,7
  • 8,4
  • 3,4
  • 9,"low"
  • 7,5
  • 3,6

Each row is the points scored in one game. Both values should be integers from 0 to 15. Only analyze records with valid data.

Here's the output:

  • Goatball
  • ========
  •  
  • Typera wins: 28
  • Vakava wins: 28
  • Draws: 14
  •  
  • Average spread: 1.97

Extra requirements:

  • Write a function called add_spread_field that takes a data set, and adds a field called Spread to each record. It returns nothing.
  • Write a function called count_results that takes a data set, and returns three values: typera_wins, vakava_wins, and draws.
  • Write a function called compute_average_spread that takes a data set, and returns the average of Spread.

Upload a zip of your project folder. The usual coding standards apply.

Attachments
Where referenced