Campfyre
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 1 day ago

Infallible Code

lemmy.ml

message-square
131
fedilink
394

Infallible Code

lemmy.ml

Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 1 day ago
message-square
131
fedilink
alert-triangle
You must log in or # to comment.
  • helvetpuli@sopuli.xyz
    link
    fedilink
    arrow-up
    1
    ·
    2 hours ago

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

  • Kuma@lemmy.world
    link
    fedilink
    arrow-up
    5
    arrow-down
    1
    ·
    6 hours 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

  • JackbyDev@programming.dev
    link
    fedilink
    English
    arrow-up
    32
    ·
    13 hours 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
      6
      ·
      8 hours ago

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

      • onlooker@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        6 hours ago

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

  • WraithGear@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    6 hours 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
      1
      ·
      1 hour ago

      well that’s the joke, isn’t it

      • WraithGear@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        1 hour 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?

  • kreskin@lemmy.world
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    13 hours ago

    no unit tests huh.

    /s

  • Treczoks@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    12 hours ago

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

  • 6stringringer@lemmy.zip
    link
    fedilink
    arrow-up
    2
    ·
    12 hours 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
    ·
    13 hours ago

    this is like the making chess one

  • sik0fewl@lemmy.ca
    link
    fedilink
    arrow-up
    10
    arrow-down
    1
    ·
    18 hours ago

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

    • PieMePlenty@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      13 hours 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
      4
      ·
      13 hours ago

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

  • Patches@ttrpg.network
    link
    fedilink
    arrow-up
    14
    ·
    21 hours ago

    Y’all laugh but this man has amazing code coverage numbers.

  • Clbull@lemmy.world
    link
    fedilink
    arrow-up
    19
    ·
    23 hours ago

    This is YandereDev levels of bad.

    • lime!@feddit.nu
      link
      fedilink
      English
      arrow-up
      6
      ·
      20 hours ago

      this is yanderedev.

      • Clbull@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        19 hours ago

        Nah, this is yanderedev

        • lime!@feddit.nu
          link
          fedilink
          English
          arrow-up
          4
          ·
          13 hours ago

          no the code is

  • kamen@lemmy.world
    link
    fedilink
    arrow-up
    19
    ·
    24 hours ago

    Plot twist: they used a script to generate that code.

  • Valmond@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    13 hours ago

    private?

  • Euphoma@lemmy.ml
    link
    fedilink
    English
    arrow-up
    20
    ·
    1 day ago
    def even(n: int) -> bool:
        code = ""
        for i in range(0, n+1, 2):
            code += f"if {n} == {i}:\n out = True\n"
            j = i+1
            code += f"if {n} == {j}:\n out = False\n"
        local_vars = {}
        exec(code, {}, local_vars)
        return local_vars["out"]
    

    scalable version

    • xthexder@l.sw0.com
      link
      fedilink
      arrow-up
      4
      ·
      22 hours ago

      Not even else if? Damn, I guess we’re checking all the numbers every time then. This is what peak performance looks like

      • lime!@feddit.nu
        link
        fedilink
        English
        arrow-up
        6
        ·
        20 hours ago

        O(1) means worst and best case performance are the same.

  • thatradomguy@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    20 hours ago

    Can you imagine being a TA and having to grade somebody’s hw and you get this first thing? lmao

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: [email protected]

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.

  • 479 users / day
  • 1.04K users / week
  • 2.38K users / month
  • 8.09K users / 6 months
  • 2 local subscribers
  • 37.2K subscribers
  • 1.38K Posts
  • 34.5K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org