In this challenge you are asked to create an alias that will return
dominos knocked over simultaneously in left and right directions.
Alias format & Parameters
The alias will be in the format:
$dominos(<pieces>,<left>,<right>)
Left and right can be a number from 0 to the len of the string $1. It represents the starting point (from the far left hand side of the string $1) to start knocking. For example, $dominos(|||,1,3) means: "start knocking from position 1 to the left and in position 3 to the right.
If 0 is supplied it means do not knock any for that direction.
Representation
Standing domino is represented by the
| character.
Domino knocked in the left direction:
\
Domino knocked in the right direction:
/
Simple examples
$dominos(|||,1,0) = \||
$dominos(|||,1,3) = \|/
$dominos(|||,0,1) = ///
$dominos(|||,3,0) = \\\
Now onto the good stuff...
Knocked at the same rate / simultaneously
The key to this challenge is dominos will be knocked
at the same rate. This means a "collision" of dominos will happen when they are being knocked towards each other. It is worth noting that because the dominos fall at the same rate there will never be an instance where you have something like:
/\\
Because then the dominos wouldn't of fallen at the same rate. The correct way is:
/|\
With a domino sandwiched in the middle. Of course with an even number of dominos this would be:
//\\
Since the dominos correctly fell at the same rate. Take a look at the examples to fully understand this concept.
The void/space
There is another aspect to this challenge and that is "the void" -- this is represented by a single space which can be placed anywhere in the pieces, and in multiple locations, which will break the flow of the dominos falling. As in real life, if you have standing dominos too far apart, they will not hit into each other. This is the same concept.
So take for example:
||| ||,5,0 = ||| \|
Since the space breaks the normal flow of the domino and the far left dominos remain standing.
Validation
No validation is needed in this challenge. You may assume correct input 0 to len of string $1 is supplied and the pieces are always in the correct format. Your alias must support at least 200 pieces/voids combined i.e. $len($1) <= 200.
If left and right are the same e.g. 1,1 this is invalid since you cannot knock both left and right from position 1 -- so this will not be tested.
Knocking from a void/space will not be tested.
Example:
|||,0,1 = ///
|||,0,2 = |//
|||,0,3 = ||/
|||,1,0 = \||
|||,1,1 = ??? -- wont be tested.
|||,1,2 = \//
|||,1,3 = \|/
|||,2,0 = \\|
|||,2,1 = /\| (knocking towards each other collison)
|||,3,0 = \\\
|||,3,1 = /|\ (knocking towards each other collison)
|||||| |||,10,0 = |||||| \\\
|||||| |||,10,1 = ////// \\\
|||||| ||| |,0,12 = |||||| ||| /
|||||| ||| |,6,12 = \\\\\\ ||| /
Rules:
Alias name must be 'dominos'
No dlls, coms, sockets
One submission per user per entry type.
Script must give correct results after consecutive runs.
Testing conditions:
Alias will be run on mIRC v6.35 and loaded into the remotes section.
Last closing bracket can be omitted }
Your code will be taken for EXACTLY as-is.
Alias will be run on a mIRC with no variables set - a clean mIRC.