Ad
  • Custom User Avatar

    i genuinely didnt like this kata

  • 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

    If any single spin scores over 100, the entire input is invalid because scoring over 100 in a single spin is impossible according to the rules of the game. The situation described by the entire input is impossible. There are no players being punished, this isn't a game happening in real time, this is the results of a game being reported to your function. Because the input received by your function is impossible, the entire game is invalid.

    What SHOULD happen to the contestants in such a game is outside of the scope of this function. In a real world scenario, if this would happen, it's likely that the game show runners would make everyone re-spin because the wheel was found to be invalid. Somehow, a wheel with a value above 100 snuck its way onto the show. Your function is not required to make this decision, the function is only specced to report this situation as invalid. If this were a computer game, as a programmer, you could conclude that you have a bug somewhere else in the code, or you could come to a conclusion that one of the players were cheating, but without more information, it's impossible to say who it is (and it wouldn't be the job of this function to determine the cheater anyway). In this case, you'd still want to report this game as invalid.

    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?

    It's not a single score (score being the result of two spins) being over 100 that results in false. It's possible for someone's score to be over 100 (for example, if they got two 70's), this would not invalidate the game. It's a single spin being over 100 that invalidates the game (again, because this should be impossible, meaning something went wrong before the scores ever got to your function).

  • 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

    I think there is a confusion between the value of the different rolls of the wheel and the total score (sum of the rolls).
    A score over 100 can occur, but a single roll of the wheel cannot exceed 100.

  • 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

    It is written in the description that numbers on the wheel are multiples of 5, ranging from 5 to 100.

  • 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

    Please note that inputs may be invalid: in this case, the function should return false.

  • Custom User Avatar

    The score for a single roll cannot exceed 100. Charlie's second roll (105) is not a valid input, hence it should return false.

  • 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

    Apologies if I am being stupid...

    [100, 250, 400, 550] should equal [100, 200, 300, 400]
    

    Why is this so when the difference between each int is already 150?

    (Marked as having spoiler content to be safe)

  • Loading more items...