For example, consider the following walk:
Move Command Right 3 r 3 Up 1 u 1 Left 1 l 1 Up 2 u 2 Left 3 l 3 Down 2 d 2 Right 1 r 1 Down 1 (closed) d 1 Down 1 d 1 Left 1 l 1 Up 1 u 1 Right 1 (closed) r 1This traces two enclosed areas: 9 units and 1 unit.
You are to write a program that accepts a list of motion commands tracing a series of perimeters, computes and prints the area enclosed by each, and prints the total area enclosed by all perimeters.
Each motion command is on a line by itself in the form given above: a single character in the first column indicating the direction (u,d,l,r), followed by a space and then an integer which indicates a distance to move in that direction.
There is no command separating the moves tracing one perimeter from those tracing the next, but each perimeter is a closed walk -- each starting and ending at the same point. This fact should be used to distinguish one perimeter from the next. Print each enclosed area as an integer, At end of file, print the total area accumulated from all walks of perimeters.
For the example given above, your program should output:
9 1 ==== 10Notes: