• Ruby 3.0 should be enabled, see this to learn how to do it

  • I just finished solving this in C# and I had no troubles with the existing test cases. But I think it is missing at least one test that should have been there.

    [25, 25, 25, 100] should return "Yes" - My currently passing solution would not pass this case, but because such a test isn't in there, my code passes.

  • Please don't post solutions in Discourse.

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

  • If you ever read a one-line solution and don't understand immediately how it works, it is probably very bad practice.

  • Don't. While many tasks can be effectively solved with a single line of code, often people will go out of their way to condense their solution into as few lines as possible in an attempt to convince themselves and others that this is "clever". Usually it's not, most often all they do is forsake readability and comprehensibility. Granted, this particular task can be solved without much code, but in general, don't be fooled by brevity. Write as many lines as you need, as long as it's readable and efficient, you're good. That said, do make a point of recognizing which built-in features of your language offer shortcuts.

  • looking at solutions in one line, I feel stupid...

  • There are random tests in javascript, that's why your code sometimes passes more or less, 12 fixed tests, 12 random.

  • I've noticed that if I submit the same function multiple times I get inconsistent results. For example, I ran the test three times and got the following output:
    14 tests passed, 10 failed
    16 tests passed, 8 failed
    17 tests passed, 7 failed

  • Please don't post solutions in Discourse. Use Solutions section for that, and even there, use spoiler flag when needed.

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

  • "and sells the tickets strictly in the order people queue"

    You are right. My fault. Thank you!

  • (test #16 with the 'NO' answer) can be obtained by the combination of two first tests:

    "NO"

    Your reasoning seems to be wrong. The two first tests do not combine into the test #16, You cannnot just join and reorder two inputs and deduce that the result will produce the same answer. Order of people in the queue matters.

  • Last 5 tests are wrong:
    For example the following test:

    test.assert_equals(tickets([25, 50, 100, 25, 25, 25, 50]), "NO")

    (test #16 with the 'NO' answer) can be obtained by the combination of two first tests:

    test.assert_equals(tickets([25, 25, 50]), "YES")
    test.assert_equals(tickets([25, 25, 50, 100]), "YES")

    (test #1 and test #2 with both 'YES' answers).

    Obviously, test #16 should also have 'YES' answer.

    The same situation is about the last tests (#17 - 20):

    test.assert_equals(tickets([25, 50, 25, 50, 100, 25, 25, 50]), "NO")
    test.assert_equals(tickets([25,50,25,100,25,25,50,100,25,25,25,100,25,25,50,100,25,50,25,100,25,50,50,50]), "NO")
    test.assert_equals(tickets([25,25,25,100,25,25,25,100,25,25,50,100,25,25,50,100,50,50]), "NO")
    test.assert_equals(tickets([25,50,25,100,25,25,50,100,25,50,25,100,50,25]), "NO")

  • In this case 1 is an exception as I understand it.

    Thank you.

  • Loading more items...