Ad
  • Default User Avatar

    I remember there is also a sequel,where the proisoners don't know the initial state of the bulb.

  • Default User Avatar

    Unfortunately, I didn't work on this one locally (Couldn't be bothered to set up the local tests with this one), so I don't have the same collections of attempts.

  • Custom User Avatar

    I am curious to see your code when it was not passing to understand why. Would you like to share it? You could help me make this kata better.

  • Default User Avatar

    I am respecting the conditions of the notes section. I can see that the message has changed. My living_room function has logic which depends only on prisoner_number, lightbulb, and previous_visits. I do not have code outside of the living room function, and I haven't introduced any additional data structures. Update: I managed to pass after shuffling around the logic.

  • Custom User Avatar

    I am not sure about what makes your solution wrong, probably something related to the Notes section, with all the rules to respect. Anyway the fork posted by Kacarott has been approved and the error messages should give you a better idea of what the problem is. Let me know if you still can't figure out what is wrong.

  • Custom User Avatar

    Yeah good catch. Closing the suggestion.

  • Custom User Avatar

    It is not easy from the tests understand why your solution is wrong. Now, the error messages should be more helpful. They will always tell you if the prisoners made an assertion too early or if they didn't make any. Anyway, if you read that message it means that your solution is probably not respecting some of the conditions in the Notes section. Let me know if you still have problems finding out what is wrong.

  • Custom User Avatar

    I found it on Mathematical Puzzles: A Connoisseur's Collection, by P. Winkler. I don't know if he is the author of the riddle.

  • Custom User Avatar

    I forked from yours to change the last message to The prisoners waited too long to make an assertion. (This might be caused by using state), then approved the forked version. Thanks for the help.

  • Custom User Avatar

    There is actually already a "Cheat test" section, which provides the living_room should be the only name in the global scope message if necessary. The random tests do not actually check that any further, and so I am not sure why it was included in their error messages.

    As for state, the tests are designed to make solutions using state to fail, but it is difficult to know whether a failing solution did indeed use state, or because of improper logic. The messages I use in the fork is: One of the prisoners made a false assertion. (This might be caused by using state) which was about as good as I could think of to handle this.

  • Default User Avatar

    can it be split to two seperate errors?

    1. living_room should be the only name in the global scope
    2. it should not have a state
  • Custom User Avatar

    The current error messages are not great, hopefully they will be fixed soon. It probably just means that your solution is wrong.

  • Custom User Avatar

    Using state means if you are somehow storing information in between function calls. The actual problem is that one section of tests only have one kind of error message, so even if you fail the tests 'normally' it still tells you that you shouldn't use state, etc.

    Probably your solution simply doesn't work, but also doesn't break any rules. I have posted a fork with slightly better messages, hopefully it'll get approved soon.

  • Custom User Avatar

    Python Fork to improve the error messages. (See issues below for context)

  • Default User Avatar

    Why This Error Message?

    Description

    When I have nothing in the global scope and do not even know what a state is, I still cannot pass with this error message:

    living_room should be the only name in the global scope, and it should not have a state
    

    In my code living_room does not have any custom attributes. Can you please suggest to me what might be going wrong here?
    I have also found that this only occurs when I assert the prisoners' freedom.
    It also only appears on a number of tests and not all of them, namely in 8~9 concentrating in the latter part of the tests.
    I can post my code if needed but I will not put it here in the question.

    Hypotheses for what might have went wrong

    1. My solution went wrong. The prisoners are not free. But this does not stand since I see that there are different messages when the result is wrong.
    2. My if-else branches, fairly naïve with only return statements in them, introduces the so called state. This is not bery possible since I myself am not consious of it.
    3. The tests have a problem. They mistake something in the code as global variables or state.

    Please help. Thank you!

  • Loading more items...