Ad
  • Custom User Avatar

    throw new Exception("This person is too dumb to survive, let's push them into the elevator shaft now and be done with it.");

    My lift doors won't open unless the lift has arrived at the floor, so there is no way to push people down shafts. Maybe try pushing them down stairs, or through a window.

  • Custom User Avatar

    headdesk

    *Every* *single* example I try works fine, but some random test gets me, or maybe a "tricky" one. But that's the key, maybe.

    Pro tip: Reset your variables on each pass. I wrote this as a class first, noticed it was expecting static, shrugged and threw static in front of everything. Who cares, nobody is going to create multiple objects anyway since the kata only calls a static method.

    Well, turns out I care since I'm using the static constructor.

    // C# is an object oriented language, so let us orient this as an object.
    public static int[] TheLift(int[][] queues, int capacity)
        { 
            Dinglemouse dinglemouse = new();
            return (dinglemouse.TheLiftX(queues,capacity));
        }
    

    Roll back to my first Git commit, toss ^^^ in, and it passes!

    Still my fault, clearing variables is Programming for n00bs 101, but I guess I'm finally thinking in objects now...

    I did decide to leave in some of the extra edgecase handling that I wrote while trying to figure out where I was going wrong, I'll leave you with this one:

    // This person wants to stay on their current floor.
    throw new Exception("This person is too dumb to survive, let's push them into the elevator shaft now and be done with it.");
    

    Although the Kata doesn't require it, I highly recommend it.

  • Custom User Avatar

    Right? Parsing back to front and then back to the back just hurts my brain. Fun though, would solve again.

  • Custom User Avatar

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

  • Custom User Avatar

    In the real world, I believe a human could figure it out based on the permutations that make up a more or less valid message compared to the others. For example, if my cat learned Morse code but wasn't great at timing, the message "FEED ME" would be more likely than "FE ED ME" due to its simplicity. However, the code itself cannot understand the context. And my cat is almost 18, cut him some slack.

    If we were guaranteed that all words belonged to a provided dictionary, it might be possible to solve this issue. However, as far as I can tell, we're stuck hoping that we have made the same assumptions as the test authors. Alternatively, we could dump their tests into exception messages to see what they're feeding and start special-handling the ambiguity as we go. It's impossible to solve an ambiguous problem unambiguously, and I'm not seeing that this one is fully defined.

    Maybe that's just me and I'm just not clever enough, which is a very real possibility too.