Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
coja ( coja@lemmy.ml )  to Programmer Humor@lemmy.ml · 3 years ago

Find yourself

lemmy.ml

message-square
45
link
fedilink
372

Find yourself

lemmy.ml

coja ( coja@lemmy.ml )  to Programmer Humor@lemmy.ml · 3 years ago
message-square
45
link
fedilink
alert-triangle
You must log in or # to comment.
  • auf ( auf@lemmy.ml ) 
    link
    fedilink
    arrow-up
    58
    ·
    edit-2
    3 years ago

    deleted by creator

    • snowe ( snowe@programming.dev ) 
      link
      fedilink
      arrow-up
      16
      ·
      3 years ago

      They’re setting a variable to a function. Just use the original function. All thief does is obfuscate for literally no gain except character count.

      • T (they/she) ( Templa@beehaw.org ) 
        link
        fedilink
        arrow-up
        3
        ·
        3 years ago

        Sounds good to me

  • davel [he/him] ( davel@lemmy.ml ) 
    link
    fedilink
    English
    arrow-up
    42
    ·
    3 years ago

    Thief. Writing code is for chumps, and the more code you right, the more of a chump you are.

    • tiredofsametab ( tiredofsametab@kbin.social ) 
      link
      fedilink
      arrow-up
      9
      ·
      3 years ago

      Writing code is for chumps, and the more code you right, the more of a chump you are.

      So you’re the one in there wronging up my code?

      • davel [he/him] ( davel@lemmy.ml ) 
        link
        fedilink
        English
        arrow-up
        6
        ·
        3 years ago

        It’s too late now to wright my wrongh ¯\_(ツ)_/¯

  • Amy ( lwhjp@lemmy.sdf.org ) 
    link
    fedilink
    arrow-up
    42
    ·
    3 years ago

    TDD

    const max12 = (x, y) => {
        if (x === 1 && y === 2) {
            return 2;
        } else if (x === 7 && y === 4) {
            return 7;
        } else {
            return x;
        }
    };
    
  • kewko ( kewko@lemdro.id ) 
    link
    fedilink
    English
    arrow-up
    20
    ·
    3 years ago

    Mathematician 2 kinda blew my mind, kinda obvious, just can’t believe I was never taught or thought about it.

    • mac ( mac@lemm.ee ) 
      link
      fedilink
      arrow-up
      3
      ·
      3 years ago

      Lost me when it used Math.abs after calling math.max a their

      • MBM ( MBM@lemmings.world ) 
        link
        fedilink
        arrow-up
        3
        ·
        3 years ago

        Math.Sqrt((x-y) * (x-y)) (I’ve actually seen someone use this)

    • Artyom ( Artyom@lemm.ee ) 
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      I’ve been staring at it for 10 minutes and I’m still not convinced it works.

      • uberrice ( uberrice@feddit.de ) 
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        Simple, really. Abs(x-y) is the difference between the two numbers, absolute, so positive value. So, adding abs(x-y) to the smaller of the two numbers turns it into the bigger number. Plus the bigger number, now you have 2 times the bigger number

  • neosheo ( neosheo@discuss.tchncs.de ) 
    link
    fedilink
    arrow-up
    17
    ·
    3 years ago

    Thief no doubt

    • Baut [she/her] auf. ( BautAufWasEuchAufbaut@lemmy.blahaj.zone ) 
      link
      fedilink
      arrow-up
      6
      ·
      3 years ago

      Thief gang. Why stand on shoulders of giants if you’re not using it to your advantage?

  • Shhalahr ( Shhalahr@beehaw.org ) 
    link
    fedilink
    arrow-up
    16
    ·
    3 years ago

    Procrastinator.

    Okay, but seriously: “Thief”. Why reimplement it if it’s already available in the language?

  • snowcatridge10 ( snowcatridge10@beehaw.org ) 
    link
    fedilink
    English
    arrow-up
    14
    ·
    3 years ago

    Thief

    • marco ( marco@beehaw.org ) 
      link
      fedilink
      English
      arrow-up
      4
      ·
      3 years ago

      And not feeling one byte bad about it :p

  • driving_crooner ( driving_crooner@lemmy.eco.br ) 
    link
    fedilink
    arrow-up
    14
    ·
    3 years ago

    Mathematician 3

    Max(x, y) = floor(ln(e^x + e^y))

    • neeeeDanke ( neeeeDanke@feddit.de ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      so 0.3 ~= 1-ln(2)=max(1-ln(2),1-ln(2)) = floor(ln(2*e^(1-ln(2)))) = floor(ln(2)+(1-ln(2))) = 1 ?

      That would bee engeneer 2, not Mathematician3 xD.

      Just out of curiostity, what was you Idea behind that?

      • driving_crooner ( driving_crooner@lemmy.eco.br ) 
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        Guess only work with integers, specially for the floor function that is going to give you an integer at the end everytime.

        Not my idea, learned it somewhere while doing college in an statistics class. The idea is that the exponential function grow really fast, so small difference on variables become extreme difference on the exponential, then the log function reverse the exponential, but because it grew more for the biggest variable it reverts to the max variable making the other variables the decimal part (this is why you need the floor function). I think is cool because works for any number of variables, unlike mathematician 2 who only work for 2 variables (maybe it can be generalized for more variables but I don’t think can be done).

        For a min fuction it can be use ceiling(-ln(e^-x + e^-y))

        • neeeeDanke ( neeeeDanke@feddit.de ) 
          link
          fedilink
          arrow-up
          2
          ·
          3 years ago

          to be fair it does seem to work for any two numbers where one is >1. As lim x,y–> inf ln(ex+ey) <= lim x,y --> inf ln(2 e^(max(x,y))) = max(x,y) + ln(2).

          I think is cool because works for any number of variables

          using the same proof as before we can see that: lim,x_i -->inf ln(sum_i/in I} e^(x_i)) <= ln(I|) +max{x_i | i /in I.

          So it would only work for at most [base of your log, so e<3 for ln] variables.

          • driving_crooner ( driving_crooner@lemmy.eco.br ) 
            link
            fedilink
            arrow-up
            3
            ·
            3 years ago

            After searching a little, I found the name of the function and it’s proof: https://en.wikipedia.org/wiki/LogSumExp

            • neeeeDanke ( neeeeDanke@feddit.de ) 
              link
              fedilink
              arrow-up
              2
              ·
              edit-2
              3 years ago

              thanks for looking it up:).

              I do think the upper bound on that page is wrong thought. Incedentally in the article itself only the lower bound is prooven, but in its sources this paper prooves what I did in my comment before as well:

              for the upper bound it has max +log(n) . (Section 2, eq 4) This lets us construct an example (see reply to your other comment) to disproove the notion about beeing able to calculate the max for many integers.

              • driving_crooner ( driving_crooner@lemmy.eco.br ) 
                link
                fedilink
                arrow-up
                1
                ·
                3 years ago

                I just remembered where I learned about that function, in this course on convex optimization that unfortunately I never had the opportunity to finishing it but is really good.

          • driving_crooner ( driving_crooner@lemmy.eco.br ) 
            link
            fedilink
            arrow-up
            2
            ·
            3 years ago

            I don’t have a mathematical proof, but doing some experimental tests on excel, using multiple (more than 3) numers and using negative numbers (including only negative numbers) it works perfectly every time.

            • neeeeDanke ( neeeeDanke@feddit.de ) 
              link
              fedilink
              arrow-up
              2
              ·
              3 years ago

              Try (100,100,100,100,100,101) or 50 ones and a two, should result in 102 and 4 as a max respectively. I tried using less numbers, but the less numbers you use, the higher the values (to be exact less off a deviation(%-difference) between the values, resulting in higher numbers) have to be and wolframAlpha does not like 10^100 values so I stopped trying.

  • Eufalconimorph ( Eufalconimorph@discuss.tchncs.de ) 
    link
    fedilink
    arrow-up
    13
    ·
    3 years ago
    #define max(x,y) ( { __auto_type __x = (x); __auto_type __y = (y); __x > __y ? __x : __y; })
    

    GNU C. Also works with Clang. Avoids evaluating the arguments multiple times. The optimizer will convert the branch into a conditional move, if it doesn’t I’d replace the ternary with the “bit hacker 2” version.

    • 14th_cylon ( 14th_cylon@lemm.ee ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      deleted by creator

      • Eufalconimorph ( Eufalconimorph@discuss.tchncs.de ) 
        link
        fedilink
        arrow-up
        1
        ·
        3 years ago

        __auto_type is a compiler builtin, not a library function. It’s not a function at all, the parentheses are for precedence & grouping.

  • bstix ( bstix@feddit.dk ) 
    link
    fedilink
    English
    arrow-up
    9
    ·
    edit-2
    3 years ago

    And then your customer changes their mind. Instead of two numbers, they will now input three numbers. How easy will it be for you to change your code?

    And then the customer changes their mind. Instead of three numbers, they will now input any series of numbers. How easy will it be for you to change your code? And why didn’t you already do this is the previous step?

    And then the customer changes their mind. Instead of any set of numbers, they will now input numbers and text. How easy will it be to change your code?

    And then the customer changes their mind. They now have no idea of what they’re sending you or if they’re even sending you anything. Nevermind the code now, you already did that in the previous step, right? How easy will it be to explain what you’re invoicing them for?

    • Natanael ( Natanael@slrpnk.net ) 
      link
      fedilink
      arrow-up
      6
      ·
      3 years ago

      How easy will it be to explain what you’re invoicing them for?

      By the hour I presume

      • bstix ( bstix@feddit.dk ) 
        link
        fedilink
        English
        arrow-up
        1
        ·
        3 years ago

        If only you’d done the most bloated and well documented function first, you could have saved yourself the time and your client for the money.

        I mean this is the kind of shit my boss would argue about. Why pay for the first attempts that didn’t work… blabla bla. He always ends up paying but it’s always such a hassle.

  • wethegreenpeople ( wethegreenpeople@sopuli.xyz ) 
    link
    fedilink
    arrow-up
    9
    ·
    3 years ago

    Engineer I guess… Thief is the objectively better enterprise programmer option but I don’t know why I always forget about it and just write a ternary ¯⁠\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯

  • cybirdman ( cybirdman@lemmy.ca ) 
    link
    fedilink
    arrow-up
    8
    ·
    3 years ago

    Master Thief const { Max: max } = Math;

  • PeriodicallyPedantic ( PeriodicallyPedantic@lemmy.ca ) 
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    3 years ago

    If thief is actually an option, then thief.

    Otherwise probably procreator or engineer 😅😬

    Edit: errrrr that was supposed to say “procrastinator” 😬dyac

  • Moxvallix ( Moxvallix@sopuli.xyz ) 
    link
    fedilink
    English
    arrow-up
    6
    ·
    3 years ago

    I’m number 11.

  • (╯°□°)╯︵ ┻━┻ ( peyotecosmico@programming.dev ) 
    link
    fedilink
    English
    arrow-up
    6
    ·
    3 years ago

    I’m in this post and I’m offended.

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.

  • 15 users / day
  • 272 users / week
  • 334 users / month
  • 1.84K users / 6 months
  • 871 local subscribers
  • 43.7K subscribers
  • 1.25K Posts
  • 10.3K Comments
  • Modlog
  • mods:
  • AgreeableLandscape ( AgreeableLandscape@lemmy.ml ) 
  • cat_programmer ( cat_programmer@lemmy.ml ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code