Law 11

From programming_contest
Revision as of 23:01, 29 December 2017 by imported>Kmk21 (Created page with "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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.