Ad
  • Custom User Avatar

    I would ask you to please mind your language on the site. Also constructive feedback goes a long way further than just insults.

  • Custom User Avatar

    I understand it's difficult to word it correctly. I would have tried to use the factory backstory to describe it, but eschewing the concept of "boxes" because it is too irrelavant to the task:

    • We are working for a factory that produces ball bearings.
    • The factory's assembly line produces batches of ball bearings. Each batch is uniquely identified by an ID / production line number, so that every bearing from this batch is labelled / engraved with this ID.
    • Due to a technical incident, the assembly line has produced one batch of 11-grams bearings instead of the usual 10-grams bearings it normally makes. We dont know which batch it was, it is the codewarrior's job to figure it out.
    • To achieve this, we have access to a scale and to an arbitrary number of samples from each batch.
    • The scale can only be used once. It can weigh an arbitrary number of bearings. The weigh function takes as input a list of the batch IDs of the bearings we want to weigh, and returns the weight of the total.
    • Our input is the weigh function and a list of unique IDs of the batches which were produced. Exactly one of those batches was the faulty 11-grams batch. We have to return the ID of this faulty batch.
  • Custom User Avatar

    Manual notification ^^

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    the setup and description of this kata really confused me. i'm not sure to which extent it's intentional not to spoil the solution.

    • There are (effectively) infinite bearings in each box

      Since the bearings have a nonzero weight, that would mean the boxes have infinite weight. Which would make the exercise pointless. It also defeats the purpose having a backstory since it stops making sense in the physical world.

    • bearings: A list of the bearing types contained in each 'box'.

      It's never explained what the "type" of a ball bearing is. Are they some kind of IDs that are guaranteed to be unique in the input list ? If so, why cannot they just be plain integers ? Does each box contain exactly one type of bearing ?

    I enjoyed the kata nonetheless

  • Custom User Avatar

    Great. Ty again for the help!

  • Custom User Avatar
  • Custom User Avatar

    Right, I did that and republished just now. Now outputs are no longer "truncated". I'll come back in a short while to make sure outputs are still correct and mark as solved if that's the case.

    I noticed our solutions produce different outputs, so I'll check wether that's a mistake in mine or yours and send an update when done.

    Thanks again.

  • Custom User Avatar

    I don't think it is resolved, I am now getting many results like this:

    4394760810501401835469614985864712016711067361490760 should equal 4394760810501401835469614985000000000000000000000000
    

    You probably need to set Decimal.getcontext().prec to be much higher.

  • Custom User Avatar

    Excuse me, I overlooked it. I unflagged my response since it doesn't really represent a relevant spoiler to the solution, at least in my opinion.

  • Custom User Avatar

    I cannot see your comment since I cannot solve the kata. You could come to the Discord (see link on the left menu) and we can discuss there. Otherwise if you want a reference you can click "view solution" under my comment to see what I think should be a correct solution.

  • Custom User Avatar

    I suspect you might have precision issues in your reference solution. For example with inputs: up=2, goal=2020450000000000000000, I calculate that we should be upgrading 126063 times, which should result in total clicks of 10684790872762699, but your tests expect 1 less at 10684790872762698.

    As the inputs get larger, the discrepency grows too.

  • Custom User Avatar

    Very hard 3kyu (at least in Agda) but very nice!

  • Custom User Avatar
  • Custom User Avatar

    It was not actually a problem with the reference solution (since no reference solution is used) but I found and fixed a bug where randomly generated nodes were not guaranteed to be unique, which may have been the problem.

  • Loading more items...