Law 11

From programming_contest
Jump to navigation Jump to search

This problem gives the positions of all the players and ball on a soccer pitch and asks you to determine who is in an offside position.

The algorithm for this problem is not difficult. One simply brute-force checks if players are

  1. on the opponents side of the field
  2. further than the second to last opponent
  3. further than the ball

The challenge is parsing the input. This becomes easy if one uses [,:\s+] as the input delimiter.