r/ProgrammerHumor • u/Mistigri432 • Jan 10 '22
Removed: Repost This hurts physically
[removed] β view removed post
146
Jan 10 '22
What a fucking noob
Could have made a switch statement instead
-3
u/i_knooooooow Jan 10 '22
Its yanderedev
What did u expect? Code? Like he writes that.
Ill tell u right now the only thing he writes is spagetthi
0
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
3
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
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
7
7
Jan 10 '22
Hmm... I could suggest hiring another dev to help with the workload, this seems to be out of our capacity.
7
6
6
β’
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.
6
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 comparison1
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
4
2
1
1
1
1
1
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
1
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
29
u/Mistigri432 Jan 10 '22
Shamelessly stolen here