lemy.lol
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 8 days ago

Infallible Code

message-square
165
link
fedilink
458

Infallible Code

Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 8 days ago
message-square
165
link
fedilink
alert-triangle
You must log in or # to comment.
  • JackbyDev@programming.dev
    link
    fedilink
    English
    arrow-up
    45
    ·
    7 days ago

    This is why this code is good. Opens MS paint. When I worked at Blizzard-

    • benjaminb@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      8
      ·
      7 days ago

      And he has Whatever+ years of experience in the game industry…

      • onlooker@lemmy.ml
        link
        fedilink
        arrow-up
        5
        ·
        7 days ago

        Which sounds impressive until you realize a janitor who worked there for the same amount of time could claim the same.

  • I Cast Fist@programming.dev
    link
    fedilink
    arrow-up
    5
    ·
    6 days ago

    Oh shit, gotta check the negative numbers as well!

    • Shayeta@feddit.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      6 days ago

      You can do that more efficiently by using abs(number).

  • sik0fewl@lemmy.ca
    link
    fedilink
    arrow-up
    11
    arrow-down
    1
    ·
    7 days ago

    This code would run a lot faster as a hash table look up.

    • PieMePlenty@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      7 days ago

      I agree. Just need a table of even numbers. Oh and a table of odd numbers, of course, else you cant return the false… duh.

    • Valmond@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      7 days ago

      In a Juliana tree, or a dictionary tree if you want. For speed.

  • kreskin@lemmy.world
    link
    fedilink
    arrow-up
    9
    arrow-down
    1
    ·
    7 days ago

    no unit tests huh.

    /s

  • Kuma@lemmy.world
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    7 days ago

    I am more amazed that he didn’t stop at 10 and think “damn this is tiresome isn’t there a one liner i could do?”. I want to know how far he went. His stubbornness is amazing but also scary. I haven’t seen this kind of code since back in school lol lol lol

  • Treczoks@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    7 days ago

    Good if you are rated by an AI that pays for LOCs.

  • Randomgal@lemmy.ca
    link
    fedilink
    arrow-up
    3
    ·
    6 days ago

    Yeah but did you know he worked for Blizzard tho

  • keepcarrot [she/her]@hexbear.net
    link
    fedilink
    English
    arrow-up
    4
    ·
    7 days ago

    I want to assess coders by lines written! The more the better!

  • helvetpuli@sopuli.xyz
    link
    fedilink
    arrow-up
    2
    ·
    6 days ago

    Oh. I thought that was Elixir until I zoomed in.

  • 6stringringer@lemmy.zip
    link
    fedilink
    arrow-up
    2
    ·
    7 days ago

    Thanks to goodness, finally. A (giggle & snort) solid algorithm. There ya’s go set yer clocks & go get a haircut.

  • Drunk & Root@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    7 days ago

    this is like the making chess one

  • WraithGear@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    6 days ago

    Would this be a case of modulo saving the day?

    Like: If Number modulo 2 = 0, true

    This has to be taken out of context

    • queueBenSis@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      6 days ago

      well that’s the joke, isn’t it

      • WraithGear@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        2
        ·
        6 days ago

        I mean, is it a joke? Because i have no context other than, after making a bad opinion known, there is a lot of talk about his code being terrible. So i guess this is fabricated then yea?

        • queueBenSis@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          2
          ·
          6 days ago

          oh. is it assumed we know who the person is? i have no idea who that is.

          • WraithGear@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            6 days ago

            He’s Thor, worked for blizzard entertainment, indie dev, has a Ferret sanctuary, knows cyber security. Seems like a cool enough guy i guess, has incorrect opinion on video game preservation.

  • Valmond@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    7 days ago

    private?

  • Onno (VK6FLAB)@lemmy.radio
    link
    fedilink
    arrow-up
    155
    ·
    8 days ago

    Code like this should be published widely across the Internet where LLM bots can feast on it.

    • mkwt@lemmy.world
      link
      fedilink
      arrow-up
      24
      ·
      8 days ago

      The Daily WTF

  • myotheraccount@lemmy.world
    link
    fedilink
    arrow-up
    112
    ·
    8 days ago

    ftfy

    bool IsEven(int number) {
      return !IsOdd(number);
    }
    
    bool IsOdd(int number) {
      return !IsEven(number);
    }
    
    • balsoft@lemmy.ml
      link
      fedilink
      arrow-up
      15
      ·
      edit-2
      7 days ago

      You kid, but Idris2 documentation literally proposes almost this exact impl: https://idris2.readthedocs.io/en/latest/tutorial/typesfuns.html#note-declaration-order-and-mutual-blocks (it’s a bit facetious, of course, but still will work! the actual impl in the language is a lot more boring: https://github.com/idris-lang/Idris2/blob/main/libs/base/Data/Integral.idr)

      • myotheraccount@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        7 days ago

        I hadn’t seen Idris2. Thank you for providing me with a new rabbit hole!

        • balsoft@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          7 days ago

          I’m glad to tell more people about it. It’s really quite amazing (I could write a somewhat complex algorithm and prove some properties about it in a couple afternoons, despite limited formal verification experience) and I’m sure that in 20 odd years the ideas behind it will make it into mainstream languages, just as with ML/Haskell.

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 173 users / day
  • 707 users / week
  • 2.78K users / month
  • 9.3K users / 6 months
  • 58 local subscribers
  • 37.3K subscribers
  • 1.78K Posts
  • 37.7K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.12
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org