Implement the function calculate_falls(instructions: str) -> int, which simulates movement based on a series of directional commands and counts the number of times the movement results in falling on a previously visited location.
Input Requirements
The function takes a single parameter:
instructions (str): A string of characters where each character can be either 'L', 'R', 'U', or 'D', representing left, right, up, and down movements respectively.
Output Requirements
The function returns an integer:
The number of times the user falls, which occurs whenever the user moves to a location that has already been visited during the simulated movement.
Movement Rules
Starting from the initial position (0, 0):
'L' decreases the y-coordinate by 1.
'R' increases the y-coordinate by 1.
'U' decreases the x-coordinate by 1.
'D' increases the x-coordinate by 1.
Additional Notes
Locations are represented as tuples of (x, y) coordinates.
The initial position (0, 0) is counted as visited before processing any commands.
Implementation File
The solution must be written in a file called /app/solution.py.