• Naich@lemmings.world
    link
    fedilink
    arrow-up
    0
    ·
    7 months ago

    Want to print out all odd numbers from 1 to 100? Easy:

    for(_=[];_<+!![]+""+[]*[]+[]*[];_++)(_%+(!![]+!![])?console.log(_):[]);

    • Naich@lemmings.world
      link
      fedilink
      arrow-up
      0
      ·
      7 months ago

      Actually, I prefer this one: for(_=[];_<+!![]+""+[]*[]+[]*[];_++%+(!![]+!![])?[]:console.log(_));

      • Naich@lemmings.world
        link
        fedilink
        arrow-up
        0
        ·
        7 months ago

        Or this one without the “undefined” when run in a browser console:

        for(_=[];_<+!![]+""+[]*[]+[]*[]-!![]-!![];_++%+(!![]+!![])?[]:console.log(_));_+!![]

          • Naich@lemmings.world
            link
            fedilink
            arrow-up
            1
            ·
            6 months ago

            _ is a variable name, [] becomes 0 when converted to an integer, !![] becomes 1. The + “” + means that the integers 1, 0, 0 get converted to a string - “100”, which gets converted back to an integer because it’s in the for loop. And there’s various other horrible conversions going on to make it all work.

    • letsgo@lemm.ee
      link
      fedilink
      arrow-up
      0
      arrow-down
      1
      ·
      7 months ago

      The previous candidate to me at a job a few years ago left the room in tears after not being able to write Fizzbuzz. On a laptop with Visual Studio installed, on their own in a an empty room with nobody looking over their shoulders. The same company said they’d had so many candidate, including university graduates, who simply couldn’t code, that they were almost giving up on it.

      • I Cast Fist@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        7 months ago

        Suddenly I feel like a fucking accomplished programmer, despite only doing some questionable stuff on Godot lately, but never messing up my loops… Not too badly anymore, anyway.

        A fizzbuzz type of question I know I would mess up on the modulo operator. I know the logic is if the division of the current_number by 3 has a remainder of zero, write fizz, but I always look up the operator

        • letsgo@lemm.ee
          link
          fedilink
          arrow-up
          0
          arrow-down
          1
          ·
          7 months ago

          Yeah it always feels like “negative logic” to me. If it’s not this and not that then don’t do the other… Does my head in. Next time I’m going to use a lookup table “x…f.bf…fb.f…” then mod15 the index. f=Fizz, b=Buzz, x=both. Nice thing about this is that it’s easier to change with the requirements. Want to shift the second fizz right one? No problem “x…f.b.f.fb.f…”. Good luck doing that with the standard approach. Add Gronk which collides with Fizz, Buzz or both at various times? Also no problem - just extend and modify the LUT accordingly and change the mod.

          I can already hear people asking why x is at the start. Arrays are indexed from 0. FizzBuzz starts at 1. 15 mod 15 is zero. Loop N from 1-100, switch on lookup[N%15], case ‘f’ print Fizz, case ‘g’ print Gronk, case ‘p’ print FizzGronk and so on. The only “nice” original feature you lose is when both %3 and %5 fire at the same time and it prints FizzBuzz without any extra code.

  • Björn Tantau@swg-empire.de
    link
    fedilink
    arrow-up
    0
    ·
    7 months ago

    I used to work at a company that used XSLT. They know that it’s an obscure language that probably none of the potential candidates have ever worked with. But it’s easy enough to learn the basics in an hour or two.

    So the entry test was to strip some tags from an XML file. You had a day or two (maybe more) to do it. My solution wasn’t ideal, I didn’t use several of the shortcuts available in the language. But at least it did what it was supposed to.

    A few weeks after I had started working there my boss came up to me, visibly frustrated and asked me whether the test was too hard. Thinking back on my problems I replied that maybe having the desired output ready so that you could test your own solution against it might be nice. But my boss’s problem was that none of the last 5 candidates could even send in a solution that would run.

    You had so much time, and running an XSLT script is really easy and takes no time at all. And for some inane reason these people couldn’t even manage to test their code and still decided to send it in.

    And I thought I was an idiot when I didn’t know if it was spelled grey or gray in CSS during the in-person interview.

    • oldfart@lemm.ee
      link
      fedilink
      arrow-up
      1
      ·
      7 months ago

      It is very good test for the ability to research, I think. The amount of people who painstakingly went through some video tutorial on PHP and are now developers is insane. I’m sure there’s place in the market for them (writing Wordpress themes/plugins, for example), but it’s hard to find a programmer with ability to think these days. Not because people are more stupid, but because every other person is a programmer now.

  • themusicman@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    7 months ago

    “Introductions and a bit of smalltalk” - I would shit myself if an interviewer started asking about smalltalk… /s

  • onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    1
    ·
    7 months ago

    I knew a dude who got a job for a programming language he never wrote. Not only that, the guy was hired to be the experienced / lead programmer to give guidance on how to use the language. In fact, I knew multiple people like this. Some were actual programmers and good at other programming languages, but some had decided it was time to switch from another field (geology, marketing, database engineer, …).

    It’s still puzzling how they got their jobs.

    Anti Commercial-AI license