Ad
  • Custom User Avatar

    The verbiage in the description is misleading because you can't actually merge "one tile." A merge by definition requires combining more than one tile. BOTH tiles are merged into one. I believe the implicit meaning here is that a tile is said to be merged if and only if it is combined into the tile on the left, which is perfectly fine, but that’s not what merge means.

    But either way, in the example, we merge the second 4 into the first, [4,4,8,16] --> [8,8,16,0], then merge the second 8 into the first [8,8,16,0] --> [16,16,0,0], and finally the second 16 into the first [16,16,0,0] --> [32,0,0,0].

    Following that procedure for the test case, we merge the second 2 into the first, [2,0,2,4] --> [4,4,0,0], and then we should be able to merge the second 4 into the first. The right 4 was never merged with a tile, so why should it be excluded from performing a final merge? If we are able to slide the 16 to the left after each merge and then finally merge it at the end (as in the above example), why can’t we do that with the 4 here?

  • Custom User Avatar

    Enabled in this fork

  • Custom User Avatar

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

  • Custom User Avatar

    Added by Johan above

  • Custom User Avatar

    implemented for JS. Java could do with that as well; the instructions are very clear about returning a new array.

  • Custom User Avatar

    added. apologies for the delay. :P

  • Custom User Avatar

    Vulnerability for input mutation fixed.
    Test for input mutation added.

  • Custom User Avatar

    Because the goal of our function is to implement "one swipe"(if this explanation makes the goal clearer):

    A given tile can only merge once. (this limits any tile to be summed/combined only 1 time)

  • Custom User Avatar

    Your solution is mutating the input array and as a consequence, the tests are misbehaving. It is indeed a kata issue because the tests should not be vulnerable to this, but at the same time your solution is not exactly correct:

    This function takes the array line as a parameter and returns a new array with the tile values from line slid towards the front of the array (index 0) and merged.

  • Custom User Avatar

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

  • Custom User Avatar

    Why isn't [2,0,2,4] == [8,0,0,0]?

  • Custom User Avatar

    Really tricky and puzzling kata to solve I'd say, compliments, I had a lot of fun with it.

  • Custom User Avatar

    Your kata was.... Unexplainably low for 6 kyu.
    Good Job on making me cry solving this :)

  • Custom User Avatar

    This Kata had me hooked on the game for a while. :-D
    Damn. Never reached 2048. I gave up crying.

  • Custom User Avatar

    so hard for 6kyu, but so interesting

  • Loading more items...