Opening your workspace…
Workspace/Coding room
Opening your workspace…
You applied for a Hunter License. You expected a fight. So far the Hunter Exam has consisted of a man in dress shoes walking down a tunnel, and several hundred applicants trying to keep up.
For this part of the exam you're roped together. The examiner hands the last applicant a piece of chalk. Every time that applicant steps somewhere new, they're supposed to mark the floor. You have a copy of the leader's route and a suspicion that the examiner will want to know how much chalk you used.
Everyone starts on the same square. Move the leader one square at a time. After each step, work down the line from front to back. If the person ahead is within one square in both coordinates, stay put. Otherwise, move one square toward them along each coordinate where your positions differ. A follower can move diagonally.
How many distinct squares does the last applicant mark? Count the starting square too.
3, [["R",4],["L",2]]Output3The last applicant marks the start and the next two squares to the right. Turning around adds no new marks.
2, [["R",2],["U",2]]Output3The last applicant moves right once and then diagonally up and right. Together with the start, that makes three marks.
Move followers in order so each sees the preceding knot after its move.
function solve(knots, moves) { // 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.