Paste: week.golf halloween

Author: razetime
Mode: text
Date: Wed, 26 Oct 2022 04:59:54
Plain Text |
Multiple lines will be given as input.
On Halloween, some people like to look for candy. So the goal of this problem is to determine how many candies people are collecting!
The first line, instructions, will be a sequence of instructions composed of the letters: B (bottom), T (top), L (left), R (right)
The other lines, form a map. The map is composed of 3 symbols: X (always be in the upper left corner of the map), - (dash), and O. X represents the player, a dash represents a place without a candy, and O a place with a candy.
For each letter in instructions, the player has to move in a certain direction on the map.
The coordinates will always be valid. Example: there will be no letters 'L' when the player is already at index 0 (or 1 if you do Lua or R) of any line.
If you pass over a square with candy, the candy will not be there if you pass over it again.
The map will always be a square and all lines have the same length <=> length of a line == number of lines.

Example:
The input is 
'RBT
XO
-O'
We start at the top left, as always.
So we go to the right, and we find a candy! Our candy counter is now at 1.
The second letter is B, we go down one square, and we find another candy! So the counter goes to 2.
The last letter is T so we go top and we are back to where we were before. However, since we have already passed this square, we don't win any new candy.
The output is therefore 2.
More info
2 ≤ length of a line ≤ 9
2 ≤ number of lines ≤ 9
1 ≤ instructions ≤ 99

New Annotation

Summary:
Author:
Mode:
Body: