• Custom User Avatar

    Very fun kata! Thanks!

  • Custom User Avatar

    Why would adding unnecessary steps be deemed clever? Is it sarcasm? Genuinely asking.

  • 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

    There is no confusion on the scoring method, there is confusion in the statement of the rules. If a single over-100 score from a single player results in the entire game being returned "false," then why does the description even account for the case where ALL players break 100? This shouldn't even need to be brought up if merely a single score invalidates the game for everyone. If such an event should result in returning "false," then it should clearly state "ANY score >100 invalidates the game." Instead, when you say "The winner one that is closest to 100 (while still being lower or equal to 100)." And then say that it should be the "winner's name" or false if "there is NO winner (ALL scored more than 100)," there is nothing to say that a single player can't score over 100, only that they can't WIN. You can eliminate the need for either of these extra sentences by just stating "Any score over 100 should return false." Why make the rules murky? There are other comments from a while back that struggle with the very same issues in the instructions.

    As for the logical/game-theory implications of the term "invalid," that's probably a separate discussion, but it seems odd to invalidate something that a player can do legally (i.e., spin the wheel twice). It's even more odd to invalidate and punish a player who legally scores 95 just because somebody else scored 110. Anyway, I just feel that the description could be made more concrete and clear-cut. I had fun solving it either way :)

  • Custom User Avatar

    Correct, which is why non-multiples of 5 are invalid, because they literally cannot occur. Scores over 100, however, CAN occur. So they are valid inputs since they are possible to attain. Closest without going over should never mean that everyone fails even if just one person goes over. If instead, any score over 100 qualifies as invalid for the entire game, no matter the other scores, why not just simply state that? Why include the case that the game is false if "there is no winner (all scored more than 100)"? You shouldn't even need to state that case if a single >100 invalidates the game ... Look, the author gets to set the rules, I'm not disputing that. The only point I'm trying to make is that we shouldn't have to infer/deduce the rules of the game. They should be stated clearly unambiguously.

  • Custom User Avatar

    The entire point of "closest without going over" is to eliminate only the players that go over ... It makes no sense otherwise. Why should one player's score invalidate my own?

    Nowhere in the description does it say that scoring more than 100 qualifies as "invalid" input. The ONLY thing it says is that in order to WIN, the score must not be over 100. If a single candidate scoring over 100 invalidates the entire game for everyone, then the sentence

    "Your solution should return the name of the winner or false if there is no winner (all scored more than 100)."

    should say

    "Your solution should return the name of the winner or false if ANYONE scores over 100."

    I understand that there can be invalid inputs (floating point numbers, integers not divisible by 5, etc.). But there is not a single statement anywhere in the description that states that a score of over 100 is "invalid", only that it can't win. The rules need to be clearer. We shouldn't have to infer conditions. "ALL candidates must score more than 100 in order to have a winner." It's that easy.

  • Custom User Avatar

    The test case:

    [
    { name: 'Bob', scores: [ 10, 65 ] },
    { name: 'Charlie', scores: [ 5, 105 ] },
    { name: 'Bill', scores: [ 90, 5 ] }
    ]

    is expecting "false" when the answer should clearly be "Bill." Interestingly, it's under the score validation category, but nothing here should return false. The description says:

    "The winner one that is closest to 100 (while still being lower or equal to 100) ... Your solution should return the name of the winner or false if there is no winner (all scored more than 100)."

    So, simply having one candidate go over the 100 mark is not sufficient for falsehood, only in the event that ALL of them break 100. Bill has the highest score here (95) without going over. I don't understand how this should be false.

  • Custom User Avatar

    I believe you are seeing only the output results. That is, [100, 250, 400, 550] is not the input you were given. Rather, it's saying that your function returned [100, 250, 400, 550] when it should have returned [100, 200, 300, 400].

    If you are having trouble figuring out why this is happening, you can try printing the test inputs on your attempts in order to see what was passed into your function. So, depending on the language you are using, you can add something like console.log(sequence) or print(sequence) as the first line of your function and that will show you exactly what your function is being passed on each iteration. This should help you nail down the problem and modify your function accordingly.

  • Custom User Avatar

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

  • Custom User Avatar

    Welp, I guess that's about as braindead as you can get. I hadn't even entered into the kata because I couldn't figure out the description, so I didn't even see the parameters. Serves me right, haha. Thanks!

  • Custom User Avatar

    I hope I'm not overthinking, but I don't understand how we will know the correct number of rows. Are all of the inputs going to be nx2 rectangles? If so, I feel like that should be stated. Instead, all that is stated is that the "length of the array will always be a multiple of the width." But what if we are given an array of length 12? Will that be a 6x2, 2x6, 4x3, or 3x4 board? It says we are expanding beyond 3x3 squares and "accepting" rectangles of "big sizes." But without knowing the dimensions, there could be ambiguous solutions. Even with the example of a 5x2 board, what's to say it couldn't have been a 2x10 board instead? All of the conditions will still have been met.

  • Custom User Avatar

    Because you linked to the original kata, which requires that the beggars choose the larger pile each time, unless they are equal, in which case they will choose the leftmost pile. Since there are no equal piles in this array, each beggar would choose the larger pile each time, leading the order 5, 4, 3, 2, 1. Your kata requires that they always choose the leftmost pile no matter what, but unless you actually state that, there is no way to know. It needs to be rewritten.

  • Custom User Avatar

    Wow, thank you. I couldn't for the life of me figure this out. That is stated nowhere in the description. This is very poorly written.

  • Custom User Avatar

    And a perfect example of ChatGPT answering the prompt correctly and you misreading it. He specifically wrote "I asked ChatGPT to explain this code ... and got exactly what he asked for.

  • Custom User Avatar

    Oh brilliant to encode the missing bar versions!

  • Loading more items...