• PhilipTheBucket@ponder.cat
    link
    fedilink
    arrow-up
    23
    ·
    1 day ago

    For-loop even number guy can get lost. Sleep-sort guy I would at least be interested to see the rest of the test. As long as he has an awareness of when not to do that kind of thing in production code, it actually might indicate he has some ability.

    • aberrate_junior_beatnik@midwest.social
      link
      fedilink
      English
      arrow-up
      4
      ·
      21 hours ago

      For-loop even number guy can get lost

      I don’t get this. Who cares if they forgot or just didn’t know the better solution? They were able to solve the problem under pressure, even if not in the most optimal way. They even remembered to handle the negative case, which is straight up a good sign (no pun intended). And while it’s slow, it would honestly still be fine to use in production anywhere you’d use typescript, as long as it’s not in a hot spot.

      In my mind this tells me approximately as much about the programmer as if they wrote it using modulo.

      • PhilipTheBucket@ponder.cat
        link
        fedilink
        arrow-up
        7
        ·
        21 hours ago

        It’s really just not a good solution. It’s more complex, it’s way slower, it shows they’re not familiar with stuff they really should be familiar with.

        Anyone who struggles to write a function to determine evenness of a number, and has to throw in some crazy solution to be able to make it across the finish line, is going to really struggle with real production code. They’re going to produce stuff that’s going to make everyone’s job a lot more difficult.

        return (x % 2) == 0;
        return (x & 1) == 0;
        return (x / 2 * 2) == x;
        return x/2 == (x+1) / 2;
        

        You can come up with unusual solutions and it can be fine. You can’t come up with cockamamie solutions, that’s why you’re doing the test.