Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. Infallible Code

Infallible Code

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
52 Posts 40 Posters 3 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K [email protected]

    You could save about half the code by only listing one boolean value and having the other as a default return at the bottom.

    Sometimes my genius is almost frightening.

    lefrog@discuss.tchncs.deL This user is from outside of this forum
    lefrog@discuss.tchncs.deL This user is from outside of this forum
    [email protected]
    wrote on last edited by [email protected]
    #11

    This noob even forgot zero

    P 1 Reply Last reply
    12
    • K [email protected]

      Better/fastest approch would be to check the last bit of the int and return the result.
      Second use modulo.

      This? Dev should burn in hell.
      Who created this?

      C This user is from outside of this forum
      C This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #12

      Yandere Simulator Dev. Spaghetti code throughout

      1 Reply Last reply
      2
      • cm0002@lemmy.worldC [email protected]
        This post did not contain any content.
        strixuralensis@tarte.nuage-libre.frS This user is from outside of this forum
        strixuralensis@tarte.nuage-libre.frS This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #13

        Try coding chess next time

        See ya in a few years

        1 Reply Last reply
        2
        • ronsijm@programming.devR [email protected]

          You don't get it. This was made in GameMaker Studio 1.4, which doesn't support a modulo operator. You know nothing about this specific framework. I have 8 years of experience and hacked governments. There's no reason to update it now, because it runs on a smart fridge at maximum capacity.

          M This user is from outside of this forum
          M This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #14

          I worked at Blizzard. I worked at Blizzard. I worked at Blizzard.

          L 1 Reply Last reply
          26
          • cm0002@lemmy.worldC [email protected]
            This post did not contain any content.
            D This user is from outside of this forum
            D This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #15

            The fact that this probably doesn't even optimize to a lookup table just gives me pain.

            1 Reply Last reply
            5
            • K [email protected]

              Better/fastest approch would be to check the last bit of the int and return the result.
              Second use modulo.

              This? Dev should burn in hell.
              Who created this?

              cows_are_underrated@feddit.orgC This user is from outside of this forum
              cows_are_underrated@feddit.orgC This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #16

              Alternatively you can divide by 2, turn it into an int, mtiply it by 2 and check if both numbers are the same.

              1 Reply Last reply
              8
              • cm0002@lemmy.worldC [email protected]
                This post did not contain any content.
                M This user is from outside of this forum
                M This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #17

                At least this madness is isolated to this function. It can easily be fixed.

                Pirate’s code is just cluttered with magic numbers everywhere. Hard coded numbers that are referring to a big ”story array”, or characters. It’s just a giant web of complexity. The only fix is to start from scratch.

                L 1 Reply Last reply
                11
                • cm0002@lemmy.worldC [email protected]
                  This post did not contain any content.
                  themoonisacheese@sh.itjust.worksT This user is from outside of this forum
                  themoonisacheese@sh.itjust.worksT This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #18

                  Obligatory: https://codegolf.stackexchange.com/q/275739/88192

                  L 1 Reply Last reply
                  3
                  • grilledcheese@lemmy.blahaj.zoneG [email protected]

                    This isn’t his actual code, right? Like this specific code pictured here? I’m aware of the “drama” surrounding him currently.

                    lime@feddit.nuL This user is from outside of this forum
                    lime@feddit.nuL This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #19

                    this is an old meme about yanderedev

                    1 Reply Last reply
                    9
                    • cm0002@lemmy.worldC [email protected]
                      This post did not contain any content.
                      S This user is from outside of this forum
                      S This user is from outside of this forum
                      [email protected]
                      wrote on last edited by [email protected]
                      #20

                      After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion

                      private bool IsEven(int number){
                        if (number > 1) return IsEven(number - 2);
                        if (number == 0) return true;
                        if (number == 1) return false;
                      }
                      
                      E E 2 Replies Last reply
                      75
                      • K [email protected]

                        Better/fastest approch would be to check the last bit of the int and return the result.
                        Second use modulo.

                        This? Dev should burn in hell.
                        Who created this?

                        T This user is from outside of this forum
                        T This user is from outside of this forum
                        [email protected]
                        wrote on last edited by [email protected]
                        #21

                        or another stupid, but viable way to do it,

                        if number = 0:

                        return true

                        runloop = true

                        while runloop:

                        if number > 0:

                        number -= 2

                        else:

                        number += 2

                        if number = 1:

                        return false

                        runloop = false

                        if number = 2:

                        return true

                        runloop = false

                        still very shitty amature coding, doesn't depend on modulos, or anything that I can think of that some languages might lack an equivelant of.

                        1 Reply Last reply
                        2
                        • S [email protected]

                          After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion

                          private bool IsEven(int number){
                            if (number > 1) return IsEven(number - 2);
                            if (number == 0) return true;
                            if (number == 1) return false;
                          }
                          
                          E This user is from outside of this forum
                          E This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #22
                          assert IsEven(-2);
                          
                          lambda@programming.devL 1 Reply Last reply
                          37
                          • S [email protected]

                            After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion

                            private bool IsEven(int number){
                              if (number > 1) return IsEven(number - 2);
                              if (number == 0) return true;
                              if (number == 1) return false;
                            }
                            
                            E This user is from outside of this forum
                            E This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #23

                            I removed the tail recursion for you:

                            private book IsEven(int number) {
                                if(number > 1) return IsEven(number - 2) == true;
                                if(number == 0) return true; 
                                if(number == 2) return false;
                            }
                            
                            U F 2 Replies Last reply
                            13
                            • E [email protected]

                              I removed the tail recursion for you:

                              private book IsEven(int number) {
                                  if(number > 1) return IsEven(number - 2) == true;
                                  if(number == 0) return true; 
                                  if(number == 2) return false;
                              }
                              
                              U This user is from outside of this forum
                              U This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #24

                              I didn't get this.

                              Why return book? Does that have some Blizzard reference?
                              And why would number == 2 ⇒ return false? This is a function for getting true when the number is even, right?

                              E 1 Reply Last reply
                              4
                              • cm0002@lemmy.worldC [email protected]
                                This post did not contain any content.
                                _cnt0@sh.itjust.works_ This user is from outside of this forum
                                _cnt0@sh.itjust.works_ This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #25

                                Not to take from all the funny answers ... but

                                bool IsEven(int i) => (i & 1) != 1;
                                

                                (C#)

                                _cnt0@sh.itjust.works_ 1 Reply Last reply
                                2
                                • U [email protected]

                                  I didn't get this.

                                  Why return book? Does that have some Blizzard reference?
                                  And why would number == 2 ⇒ return false? This is a function for getting true when the number is even, right?

                                  E This user is from outside of this forum
                                  E This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by [email protected]
                                  #26

                                  Haha, you're right. I've now learned two things:

                                  1. I should not write code on a mobile
                                  2. I should not become a proof reader

                                  At the end of the day i just wanted the function to be worse, by causing stack overflows

                                  1 Reply Last reply
                                  12
                                  • _cnt0@sh.itjust.works_ [email protected]

                                    Not to take from all the funny answers ... but

                                    bool IsEven(int i) => (i & 1) != 1;
                                    

                                    (C#)

                                    _cnt0@sh.itjust.works_ This user is from outside of this forum
                                    _cnt0@sh.itjust.works_ This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #27

                                    Though, obviously I had to come up with some ridiculous solutions:

                                    bool IsEven(int i) => ((Func<string, bool>)(s => s[^1] == 48))($"{i:B}");
                                    

                                    This one works without conditionals 🙂

                                    bool IsEven(int i)
                                    {
                                        try
                                        {
                                            int _ = (i & 1) / (i & 1);
                                        }
                                        catch (Exception)
                                        {
                                            return true;
                                        }
                                    
                                        return false;
                                    }
                                    
                                    L 1 Reply Last reply
                                    0
                                    • cm0002@lemmy.worldC [email protected]
                                      This post did not contain any content.
                                      typewar@infosec.pubT This user is from outside of this forum
                                      typewar@infosec.pubT This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #28

                                      Lol the amount of bullying this guy is getting lately. I've seen similar spins and bends that looks somewhat legit, making people believe he suck at coding

                                      1 Reply Last reply
                                      8
                                      • cm0002@lemmy.worldC [email protected]
                                        This post did not contain any content.
                                        tux0r@feddit.orgT This user is from outside of this forum
                                        tux0r@feddit.orgT This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #29

                                        Then again, Duff’s Device works rather similarly.

                                        1 Reply Last reply
                                        4
                                        • xxce2aab@feddit.dkX [email protected]

                                          Pah, mathematicians and their generally applicable pure approach to solutions and fancy modulus operations, who needs 'em? Computing is applied and we always work with well-defined finite precision. Granted, writing the boilerplate for all possible 64 bit integers is a bit laborious, but we're programmers! That's what code generation is for.

                                          J This user is from outside of this forum
                                          J This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #30

                                          Granted, writing the boilerplate for all possible 64 bit integers is a bit laborious,

                                          I've been trying to figure out roughly how many lines of code that would equal out to but I've run out of fingers.

                                          xxce2aab@feddit.dkX 1 Reply Last reply
                                          1
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups