Ad
  • Custom User Avatar

    That was fun. Thanks for your effort. But I bet you had more fun writing it.

    And to the haters... you only dislike this kata because it is beyond your comprehension. Try a lower level kata.

  • Custom User Avatar

    @cforsyth68 I added function, thanks.
    I also used description you sent - thanks for that too.

  • Custom User Avatar

    the initial cod needs "function" in front of "findBall(scales) {"

    otherwise, i think you got it. thx

  • Custom User Avatar
  • Custom User Avatar

    I feel it would be beneficial to add "function" in front of "findBall(scales) {", though, this is 5 kyu, :) people should know they have to add it.

  • Custom User Avatar

    @tiriana, consider using Preloaded section to define something but hide it from user. Maybe it can help designing example test cases (I'm not sure if it actually helps, I just wanted to highlight the possibility).

  • Custom User Avatar

    May I suggest something like this:

    Your function - findBall will receive single argument - scales object. The scales object contains an internally stored array of 8 elements (indexes 0-7), each having the same value except one, which is greater. It also has a public method named getWeight(left, right) which takes two arrays of indexes and returns -1, 0, or 1 based on the accumulation of the values found at the indexes passed are heavier, equal, or lighter.

    Your job is to write a method - findBall(scales) which will take the scales object and call its getWeight() method only twice to determine which index of the internal array has a greater weight.

  • Custom User Avatar

    @MMMAAANNN Great idea - thx for that, I will add it to description.

  • Custom User Avatar

    MMMAAANNN, that helps.

    I simply want to know the method signature, including the expected result.

    For example:

    findBall(arrayOfBalls) {
    // call scales.getWeight() only twice
    return indexOfHeavyBall;
    }

    In addition, I think adding a couple example unit tests would help the most. At least then we know what the method accepts as parameters and what to expect as output.


    tiriana, your spelling errors should also be corrected.

    "Your function - findBall will receive single argument - scales object. ----> I has only one method <----"

    You sound like you're speaking Engrish. I suggest finding someone who speaks English to proofread for you.

    You should also define what a "single argument" is exactly. Is it an array of integer values representing ball weights? If so, say that! Please avoid ambiguity. This isn't an in-person interview where we are able to ask you clarifying questions, so you need to be clear from the start.

  • Custom User Avatar

    You should probably add an example of how .getWeight() method is used. Like this:

    Examples of scales.getWeight() usage:
    scales.getWeight([3], [7]) returns -1 if ball 3 is heavier than ball 7, 1 if ball 7 is heavier, or 0 i these balls have the same weight.
    scales.getWeight([3, 4], [5, 2]) returns -1 if weight of balls 3 and 4 is heavier than weight of balls 5 and 2 etc.

  • Custom User Avatar

    Hello :)

    I must say that 'This is the worst Kata I've seen' made my day :) I admit - the instructions could have been more clear, but to call it 'the worst'? :) I LOLed hard, thanks for that.

    I changed the description - please let me know if it's better now.

  • Custom User Avatar

    How did this get thru beta? This is the worst Kata I've seen. Clear up the instructions! I solved this but there's no clear instructions for how the solution should be implemented. Where does the 8 element array of numbers come from? What should the method return?

    I wish there was a way to down vote.

  • Custom User Avatar

    You should add these test cases, where first is not capitalized, or call it Pascal case instead...

    Test.assertEquals(toCamelCase("_the-stealth-warrior"), "theStealthWarrior");
    Test.assertEquals(toCamelCase("-the-stealth-warrior"), "theStealthWarrior");