or u can save the calculations
It will even throw an error if not an array. @_@
Because sometimes we want to convert from one type to another.
nice kata, with a touch of computer history and knowledge
this was fun to look at all the very different ways it was solved
Yes, you pass a sample in the form of two arrays which you have to create yourself to scales.getWeigh() and it returns a response. For example, if ball 1 is the heavy ball, the following will happen:
measurement = scales.getWeigh([0, 1], [2, 3]) ---> measurement === -1
measurement = scales.getWeigh([0, 2, 3], [4, 5, 6]) ---> measurement === 0
measurement = scales.getWeigh([0, 2, 3], [1, 5, 6]) ---> measurement === 1
This comment is hidden because it contains spoiler information about the solution
Power and root are inverse operations, so your myPow function can with a very small modification be used to compute root instead.
"Input will always be a non-negative integer."
Not good when we got negative numners
@VladimirZd: You only showed myPow, but you didn't show us how you used that function. That might be an integral part. The numbers may differ at the 12th digit, so it would be interesting to see your actual complete solution.
Nope; I didn't calculate power nor did any other solutions I saw. Your function works " "fine" " , I mean it returns wrong result because of JS floating point issues.
Passing solutions compute more "directly" the root and eventual remaining floating point issues are handled by an assertFuzzyEquals function bkaes-san wrote for us ( どうもありがとう！Dōmo arigatō! ).