#C6717. Next State in Lavaland
Next State in Lavaland
Next State in Lavaland
In Lavaland, every cell in the landscape can be in one of two states: V
(volcanic rock) or L
(lava rock). The transformation rule is as follows:
- A cell already in state
V
remains unchanged. - A cell in state
L
will change toV
if at least one of its adjacent cells (either to the left or right) is in stateV
.
Your task is to compute the next state of Lavaland given an initial state represented as a string. Note that the transformation is applied simultaneously based on the original state.
For example:
Input: VVLVLLLV Output: VVVVVVVV</p>Input: LLLL Output: LLLL
Input: LVLV Output: VVVV
Make sure to read the input from stdin
and print your answer to stdout
.
inputFormat
The input consists of a single line containing a string of characters. Each character is either V
or L
, representing a cell in Lavaland.
You can assume that the string is non-empty and its length does not exceed typical constraints for contest problems.
outputFormat
Output a single line containing the resulting string after applying the transformation rules. The output should be printed to stdout
.
VVLVLLLV
VVVVVVVV