I'm not enough of an expert to answer your question, but would like to mention that it is possible (though not necessarily better) to solve this without using switch or if statements.
I think I corrected this now. But some solutions still show up as invalid, even though I tried to copy-paste them and they actually work fine with new test cases. Could be some CW glitch.
EDIT: All good by now, all valid solutions with old names are valid again.
You changed it to a wrong name. should be 'nameShuffle' or 'nameShuffler'. As far as I know, there is no word 'suffle' or 'suffler' in English.
Also, when you change the main function name, consider adding support for the old name as well, because otherwise all old solutions become invalid. To do provide back-compatibility, just add a line like this to the test cases:
Balls are random and hiden in scales object. You will receive scales during test cases. You can only use scales.getWeight(leftPan, rightPan).
Let's say that randomly generated balls are [1,1,1,1,1,1,1,2] - last ball is heavier. In such case findBall should return 7 - index of heavier ball.
I've just added some example scales you can use for testing: exampleScales_firstBallHeavier, exampleScales_secondBallHeavier, exampleScales_lastBallHeavier. They are global so please try to play with them.
🦊
I'm not enough of an expert to answer your question, but would like to mention that it is possible (though not necessarily better) to solve this without using switch or if statements.
I think I corrected this now. But some solutions still show up as invalid, even though I tried to copy-paste them and they actually work fine with new test cases. Could be some CW glitch.
EDIT: All good by now, all valid solutions with old names are valid again.
Ok
If you are ok with it, I'll do the work that MMMAAANNN suggests :)
can you gimme the whole test case :)
You changed it to a wrong name. should be 'nameShuffle' or 'nameShuffler'. As far as I know, there is no word 'suffle' or 'suffler' in English.
Also, when you change the main function name, consider adding support for the old name as well, because otherwise all old solutions become invalid. To do provide back-compatibility, just add a line like this to the test cases:
yeah i'll change tq:)
Hello.
Balls are random and hiden in
scales
object. You will receivescales
during test cases. You can only usescales.getWeight(leftPan, rightPan)
.Let's say that randomly generated balls are [1,1,1,1,1,1,1,2] - last ball is heavier. In such case
findBall
should return7
- index of heavier ball.I've just added some example scales you can use for testing:
exampleScales_firstBallHeavier
,exampleScales_secondBallHeavier
,exampleScales_lastBallHeavier
. They are global so please try to play with them.If you have any more doubts - please ask ahead.