25
2
Using the fewest Unicode characters, write a function that accepts three parameters:
- Total number of dominoes
n
th affected domino- Topple direction of the affected domino (
0
orL
for left,1
orR
for right)
Once a domino is toppled, it must also topple the remaining dominoes in the same direction.
You should output the dominoes with |
representing a standing domino and \
and /
representing a domino toppled to the left and right respectively.
Examples
10, 5, 1
should return ||||//////
6, 3, 0
should return \\\|||
Should the third parameter be a string or will a bool/int do like 0:left , 1:right? – user80551 – 2014-07-09T18:11:11.333
Your example suggests that if there are 10 dominoes, and 5 are knocked right, we should display six of the ten dominoes knocked over. – algorithmshark – 2014-07-09T18:21:57.807
1@algorithmshark I think we should show the result if the fifth domino is knocked right. – user80551 – 2014-07-09T18:22:41.383
@rybo111 Can you allow the third parameter to be an int as that can make comparison operations shorter. Simply
if(third_parameter)
instead ofif(third_paramter=='l')
– user80551 – 2014-07-09T18:42:46.797Can we choose the order of the parameters? – Justin – 2014-07-09T18:52:18.450
Alright, use whichever parameter order and the direction can be an int or a string – rybo111 – 2014-07-09T18:58:59.213
And my example is correct: if you knock over the 5th domino, to the right, it also knocks over the remaining dominos to the right. – rybo111 – 2014-07-09T18:59:36.763
Shouldn't right make
//////||||
? Your example doesnt start at the beginning... – Martijn – 2014-07-10T14:06:31.913@Martijn The example parameters are
10, 5, 'r'
- this translates to: There are10
dominos. Knock the5
th one to ther
ight. This means the 5th domino becomes knocked over (/
) as does everything after it. However, if you change ther
to anl
, the output would be\\\\\|||||
because when you knock a domino left it would knock over everything before it instead. – rybo111 – 2014-07-10T14:35:12.240IMO a bit weird principle for dominos. I Interpreted it as
10 dominos, 5 have allready fallen in the direction R
. Guess I'll have to update my code – Martijn – 2014-07-10T14:46:37.263@Martijn Well, the principle of the domino effect is that one change causes others to change. I'd rather specify one change than specify all the changes – rybo111 – 2014-07-10T15:01:04.977
Mine was assuming the items where still falling, more like s snapshot. But updated my code – Martijn – 2014-07-10T15:05:05.073
@Martijn if it's any consolation, I interpreted as you did as first as well ^.^ – Cruncher – 2014-07-10T18:53:06.857