Opening your workspace…
Workspace/Coding room
Opening your workspace…
Harry is flying as Seeker during a Quidditch match. Each turn, you know Harry’s position and the Golden Snitch’s position on the pitch. Find the first turn when the Snitch is within Harry’s sight range. Return its zero-based turn number, or -1 if he never spots it.
[[0,0],[3,4],[8,8]], [[10,0],[6,8],[8,10]], 5Output1On turn 0 they are 10 units apart. On turn 1 they are 5 units apart, so Harry spots the Snitch then.
[[1,1],[2,2]], [[4,5],[6,6]], 2Output-1The Snitch stays farther than 2 units away on both turns.
Compare squared distances with the squared sight range.
function solve(harryPositions, snitchPositions, sightRange) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.