Law 11
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
- on the opponents side of the field
- further than the second to last opponent
- further than the ball
The challenge is parsing the input. This becomes easy if one uses [,:\s+] as the input delimiter.