Opening your workspace…
Workspace/Coding room
Opening your workspace…
The ferry is a snail. You can tell where it's been by the silver trail along the canal bed, which is handy because you charge the ferryman by the square of canal that needs scrubbing. Start at (0,0) and move one square for each N, S, E, or W in the route. How many different squares need a scrub? Include the dock, even if the snail never left.
"NESW"Output4The ferry visits (0,0), then (0,1), (1,1), (1,0), and returns to (0,0). The dock square is revisited, so there are 4 distinct squares.
"NNSS"Output3It visits (0,0), (0,1), (0,2), then returns through (0,1) to (0,0): 3 distinct squares.
Record every position, including the dock before the first move.
function solve(route) { // 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.