Thanks to this question for some inspiration
In this challenge we will represent a line of dominoes as a string of |
, /
and \
. You will be given a string of dominoes as input and you must determine what they look like when they have settled. Here are the rules for how dominoes fall over
A standing domino,
|
, left of a left fallen domino,\
, will become a left fallen domino as well.A standing domino,
|
, right of a right fallen domino,/
, will become a right fallen domino as well.If a standing domino is between a left fallen
\
and a right fallen/
domino, it will remain standing.
These rules are applied repeatedly until the arrangement no longer changes.
Here is an example of how a single input might arrive at its conclusion
|||||||\/|||||||\||\|||/||||||\|||||
||||||\\//|||||\\|\\|||//||||\\|||||
|||||\\\///|||\\\\\\|||///||\\\|||||
||||\\\\////|\\\\\\\|||////\\\\|||||
|||\\\\\////|\\\\\\\|||////\\\\|||||
||\\\\\\////|\\\\\\\|||////\\\\|||||
|\\\\\\\////|\\\\\\\|||////\\\\|||||
\\\\\\\\////|\\\\\\\|||////\\\\|||||
Your task is to write code that finds and outputs the end result of a input. You may assume that the input is always valid and contains at least 2 characters.
This is code-golf so answers will be scored in bytes with fewer bytes being better.
Test cases
|||/|||| -> |||/////
|||\|||| -> \\\\||||
|/||||\| -> |///\\\|
||/|||\| -> ||//|\\|
||\|||/| -> \\\|||//