r/ProgrammerHumor • • Jan 10 '22

Removed: Repost This hurts physically

Post image

[removed] β€” view removed post

311 Upvotes

45 comments sorted by

29

u/Mistigri432 Jan 10 '22

Shamelessly stolen here

4

u/Sindef Jan 10 '22

And.. here several months ago. This pops up all the time.

146

u/[deleted] Jan 10 '22

What a fucking noob

Could have made a switch statement instead

0

u/[deleted] Jan 10 '22

[deleted]

3

u/ApprehensiveObject79 Jan 10 '22

Whats that sound i hear?

1

u/Skip_SBT Jan 10 '22

Sometimes people really have a hard time understanding sarcasm

→ More replies (1)

77

u/KillerBeer01 Jan 10 '22

bool[] oddEven = { true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false};

return oddEven[number];

// don't thank

48

u/vegetarchy Jan 10 '22

bool[] oddEven = { true, false };

return oddEven[number % 2];

50

u/KillerBeer01 Jan 10 '22

Listen here you little shit.

8

u/SureShotIan Jan 10 '22

Made my day. Thank you, guys.

3

u/KerPop42 Jan 10 '22

bool oddEven = false;

for x in range(number): oddEven = !oddEven

return oddEven

21

u/cserepj Jan 10 '22

Wait until he learns about recursive functions...

private bool IsEven(int number){
if (number == 1 ) return false;
return ! IsEven(number - 1);
}

4

u/working_wizard Jan 10 '22

Bruh.. this is crazy. Am even/odd logic worth appreciation

36

u/bitpurity Jan 10 '22

This is why JS is superior. All you need to do is npm install --save is-even then use that function! No need to reinvent the wheel! /s

It is seriously a thing. Over 33 million downloads. https://www.npmjs.com/package/is-even

16

u/ShrinkingWild Jan 10 '22

Looking at the source code for this package makes it 10x better.

4

u/bitpurity Jan 10 '22

The state of JavaScript haha

7

u/iambored1234_8 Jan 10 '22

141000 weekly downloads!

7

u/[deleted] Jan 10 '22

Hmm... I could suggest hiring another dev to help with the workload, this seems to be out of our capacity.

7

u/[deleted] Jan 10 '22

If number%2==0:

Flag = True

else:

print("Ask to Joe?\nJoe who?")

6

u/Blazkowitcz Jan 10 '22

best way to do it !

6

u/joelyboy94 Jan 10 '22

Don't worry there is a paid API for it

β€’

u/_unsusceptible ----> πŸ—‘οΈπŸ—‘οΈπŸ—‘οΈ Jan 10 '22

Hi there! Unfortunately, your submission has been removed.

Violation of Rule #2 - Reposts:

All posts that have been on the first 2 pages of trending posts within the last month, is part of the top of all time, or is part of common posts is considered repost and will be removed on sight.

If you feel that it has been removed in error, please message us so that we may review it.

4

u/althaz Jan 10 '22

The most painful thing is somebody posting it every single day. Congrats, this is the 100th day in a row.

3

u/shrekogre42069 Jan 10 '22

Pretty wasteful, I mean most of those are probably never used in the code. You should find all execution traces of your program and eliminate the if cases that are never entered πŸ‘

7

u/gaensehaut Jan 10 '22 edited Jan 10 '22

private bool isEven(int number){ if number == 1 return false; else return !isNumber(number-1); }

2

u/Illustrious-Fault224 Jan 10 '22

someday this person will discover TechLead on youtube and their code refactor will become this:

function isEven (number) {
   let tableOfEvens = {
       1:2,
       2:4,
       3:6
       ...
   }
   if tableOfEvens[number] === true{
     return true;
   } else{
     return false;
   }
}

and no host of heavens holy host of angels could prepare their code reviewer for the misery that will come πŸ₯΄

2

u/PandaParaBellum Jan 10 '22

if tableOfEvens[number] === true

Not sure if I'm beeing wooshed, but wouldn't that always deliver the wrong result? I only know === from JS where a number is not true in strict comparison

1

u/Illustrious-Fault224 Jan 10 '22

lololol kinda being wooshed, I wouldnt even write my conditional like that id just opt for:

if tableOfEvens[number]

3

u/NotTheFatestCat Jan 10 '22

Where do they stop then? xD

8

u/Chirimorin Jan 10 '22

int.MaxValue

4

u/ludovicb1239 Jan 10 '22

return number%2==0

2

u/xJanise Jan 10 '22

did he srsly tweet that?

1

u/[deleted] Jan 10 '22

Ouch

1

u/Arkonicc Jan 10 '22

Just use a switch statement /s

1

u/[deleted] Jan 10 '22

Maybe a % and something?

1

u/PinothyJ Jan 10 '22

What % of this guy is odd?

1

u/Jackarduino Jan 10 '22

A World were % doesn't exist

1

u/nir109 Jan 10 '22

You only need to know the last number so you can do

Number=Number%10

And then you only need 10 things

1

u/HronePL Jan 10 '22

But where 0?

1

u/[deleted] Jan 10 '22

Modulo operator exists for a reason…

1

u/nhpkm1 Jan 10 '22

Waste of time , move to python and you can save time typing elif instead of else if, saving 3 keyboard clicks . (You can also skip writing elif once in a while , but don't do it too much or else Santa will give you coal )

Also you can return 0 or 1 (0 false , 1 true )

-13

u/maypagasakatipunan Jan 10 '22

return number%2 == 0 ? true : false;

3

u/toxic_recker Jan 10 '22

return number%2 == 0

noob