Skip to content
DevMeme
2075 of 7663
CS Fundamentals Post #2320 · source on Telegram

When a Programmer Solves a Math Problem

Description

A text-only meme on a white background. The first line presents a challenge from a math teacher: 'Math teacher: get 6 with only numbers 1, 2, 3, 4 and basic operations'. The second part of the meme presents a clever, domain-specific solution: 'Me (an intellectual): 3<<4>>2>>1'. There is a small watermark in the bottom left corner for 't.me/dev_meme'. The humor is rooted in the creative interpretation of 'basic operations'. While a math student would think of addition, subtraction, multiplication, and division, the 'intellectual' (a programmer) uses bitwise shift operators, which are fundamental in low-level programming but not in elementary arithmetic. The expression evaluates to 6 (3 << 4 is 48, 48 >> 2 is 12, 12 >> 1 is 6), correctly solving the puzzle in a way that showcases a programmer's distinct problem-solving mindset

Comments

50
Anonymous ★ Top Pick The math teacher was looking for `(4-1)*2/3` or something. They weren't prepared for a solution that's O(1) in terms of cognitive overhead for a programmer, but requires explaining binary to the rest of the class
  1. Anonymous ★ Top Pick

    The math teacher was looking for `(4-1)*2/3` or something. They weren't prepared for a solution that's O(1) in terms of cognitive overhead for a programmer, but requires explaining binary to the rest of the class

  2. Anonymous

    Nothing says “senior engineer” like turning a middle-school math problem into 3<<4>>2>>1 - then spending the rest of the sprint debating whether it should be an arithmetic or logical shift across four languages and two compilers

  3. Anonymous

    When you've spent so many years optimizing embedded systems that you instinctively reach for bit shifts instead of multiplication, only to realize the compiler would've done it anyway - but hey, at least you saved those precious 3 CPU cycles in 1987

  4. Anonymous

    When your solution is technically correct but uses O(log n) brain cells where O(1) would suffice - because why write '1+2+3' when you can demonstrate your intimate knowledge of CPU instruction sets? This is the software equivalent of using a distributed microservices architecture to calculate 2+2, proving once again that the shortest path between two points is a bitwise operation that makes your code reviewer question their career choices

  5. Anonymous

    It evaluates to 6 - until someone runs it on a negative int and we spend the retro arguing arithmetic versus logical right shift

  6. Anonymous

    Arithmetic? Too basic. Real devs approximate 6 with a syntax error and a straight face

  7. Anonymous

    3<<4>>2>>1 - because to anyone raised on Hacker’s Delight, “basic operations” includes the barrel shifter; correct at the ALU, guaranteed to start a code review about precedence and sign-extension

  8. @pyproman 6y

    But you could just 2*3 or 4+2 or 1+2+3

    1. @Four_Velocity 6y

      But then you're not an intellectual

    2. @yyuriykiss 6y

      3^2+1-4

      1. @desperado_gmbh 6y

        caret means XOR, so 1+(2^3)+4

      2. @zherud 6y

        how the fuck is power a basic operation?

        1. @tyomych88 6y

          Это ХOR

          1. @zherud 6y

            а ну да, 3XOR2+1-4=-2=6

    3. @Juliaz852 6y

      The point is to use all of them

      1. @pyproman 6y

        So, 2|4*1**3?

        1. @minicooper666 6y

          Explain that.

        2. @feskow 6y

          Is it like a | b returns a+b?

          1. @Juliaz852 6y

            It's bytewise or

            1. @feskow 6y

              Makes sense now, that's cool

          2. @pyproman 6y

            In this case, yes.

      2. @t_Shatterhand 6y

        1+4+3-2

  9. @tyomych88 6y

    It sais BASIC operations The guy uses C

  10. @yyuriykiss 6y

    Still not intellectual

  11. dev_meme 6y

    Image text: Math teacher: get 6 with only numbers 1, 2, 3, 4 and basic operations Me (an intellectual): 3<<4>>2>>1

    1. Deleted Account 6y

      (1+3+4)-2?

    2. @I_like_trains 6y

      So, ((3x4)/2)/1, do I get it right?

      1. dev_meme 6y

        Y'all just too smart for this shit, wouldn't you mind unsubscribe?

  12. @d3p43x 6y

    4*3/2*1

    1. dev_meme 6y

      Y'all just too smart for this shit, wouldn't you mind unsubscribe?

      1. @I_like_trains 6y

        Ahah, lol

  13. @tyomych88 6y

    (4|2) * (1&3)

  14. @slnt_opp 6y

    4 + 3 + 1 - 2

  15. @I_like_trains 6y

    Funny that it matched, though

    1. dev_meme 6y

      Of course it does!

    2. dev_meme 6y

      Did you think we're joking here?

  16. @I_like_trains 6y

    Nah, I think we're 3 -> 48 -> 12 -> 6 here

  17. @tyomych88 6y

    Int(Asc(Int(Str(1*2+3) + Str(4))))

  18. @tyomych88 6y

    (1|2)<<(4-3)

  19. @tyomych88 6y

    (1+2)**3/4

  20. @Cinill 6y

    4\2*3*1

  21. @Cinill 6y

    4-2+3+1

  22. @Cinill 6y

    Остальное избыточно

  23. @b4dapp13 6y

    4 | 3 | 2 - 1

  24. @p4vook 6y

    lol I can do it with 3 different operations 2 * 4 - 3 + 1

  25. @feskow 6y

    I wonder how many ways you can get 6 using basic operations

    1. @p4vook 6y

      infinite number of ways

      1. @feskow 6y

        Using only 4 numbers that are given

        1. @feskow 6y

          And 4 times

  26. Deleted Account 6y

    1+2+3+4-4

Use J and K for navigation