5 kyu

Find heavy ball - level: master

776 of 1,741tiriana
Description
Loading description...
Puzzles
Logic
Riddles
  • Please sign in or sign up to leave a comment.
  • trashy_incel Avatar

    C translation (author inactive)

  • Glinator Avatar

    OCaml translation.

    Please review and approve, thanks !

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • nithin5426 Avatar

    I tried to exploit the life attribute of the object and it worked for the practice cases. How did you remove it for the tests

  • GiacomoSorbi Avatar

    Ruby, Crystal and c++ translations kumited :)

  • zebulan Avatar

    @tiriana,

    This kata isn't compatible with Python 3 because of xrange.

  • xenic Avatar

    Why are there 200 test cases when there are only 8 possible cases?

  • ekailia Avatar

    expecting the n-ball kata

  • Hacker Sakana Avatar

    Python version kumited. Took some measure in case of cheating. :)

  • Hacker Sakana Avatar

    Had fun with three katas of this series. :)

  • shankararunachalam Avatar

    Too simple for 5kyu IMO :)

  • hksong Avatar
    1. The getWeight instance method does not break after two uses. Perhaps you should include a @scale_used to keep track of the number of uses. It should only be a couple of lines of code.

    2. The getWeight instance method only takes Array as arguments, but your example code passes in Number/FixNum. This is very misleading. Either modify the method to coerce the value or change your example code.

  • hksong Avatar

    This puzzle is sort of well known. Since the solution to find the heavier ball out of n-th is readily available, this should be 6 or 7 kyu.

    Or you can try to make it more difficult by having one ball differ in weight but let the coder find out which ball and which direction (heavier/lighter).

  • ile_goldx Avatar

    Loved it! Very nice logical puzzle - hard to get at first but very easy to code when you 'get it'.

  • epinto Avatar

    Hi.

    Why the instructions says you can use the scale twice but a commentary in code says that you can use max 4 times?

    Thanks for your answer.

  • cforsyth68 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.

  • Nemesisesq Avatar

    Is it possible to get some testcases written for this. The Kata is completely unclear as to where the array datastructures are coming from given that we're supposed to be manipulating them. It's a nice riddle though.

  • palmerj3 Avatar

    The instructions don't say what the function is supposed to return. I assumed it wanted the index of the ball and I was right but it should say that.

  • wthit56 Avatar

    Loved these tests. Good job!

  • LDeleuran Avatar

    Perhaps make default code for the students to test with. This would make it clear how to use the scale input parameter.

  • LDeleuran Avatar

    Really good riddle. Thanks for putting it up as a kata.

  • Azuaron Avatar

    This is one of those kata that the difficulty is difficult to rate. On the one hand, the programming required to solve it, once you know how, is trivial. On the other hand, solving the problem is quite difficult (if you don't know it already). I just don't know...

  • SagePtr Avatar

    Typo in tests:

    if (!areBallsValid(rightPan)) {
      throw 'There are invalid balls on left pan ' + leftPan.join();
    }
    

    Should be 'right'.