Ad
  • Custom User Avatar

    Outputs:

    A list of tuples, with the state of the two jugs after every step

    That initial [0,0] should not be there, and that is specified ( note it says "after" every step ).

    Not a kata issue - but I am going to raise it as a suggestion; that initial (0,0) can very easily be checked for and passed.

  • Custom User Avatar

    Hey you who is trying to solve this, non spoiler-ish tips:

    • you gotta know a math trick
    • write equality on paper, and do some algebra.

    both tips are unrelated.

  • Custom User Avatar

    Well, thank you for reminding me that basic advice, turned out that was super easy after all.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    look more carefuly at the description : it mentions the method getNext() to get the next node. So, in order to get the next node, you can do node = node.getNext().

    the node object is given as an argument, and is an instance of a custom class defined somewhere else.
    As the challenge require you don't modify these, it does not really matter what its implementation is.

  • Custom User Avatar

    Best solution by far, as far as I can tell, the only one worthy of production : readable, no loop, shortly and well documented.

  • Custom User Avatar

    You'd gain vertical space and a bit of performance by using list comprehensions. Also, you could treat directly array1 and array2 without any intermediary variables

    cheer :)