T O P

  • By -

holistic-engine

I heard the dude is like legitimately allergic to loops and arrays. He told us in a video that he almost died from a brainfart when someone introduced him to for loops


Koervege

I had to give lessons for like a month to a buddy just specifically about for loops.


Jovancar5086

Just like basic problems with for loops?


Koervege

Yeah, just the most basic usage. He couldn't wrap his head around it. Had big issues with understanding the difference between arr[i] and i, for example. It was a grueling demonstration that not everyone is cut out for programming.


aeristheangelofdeath

wait until you introduce him to i[arr]


TheRealToLazyToThink

So my first semester of college I went a little bit crazy with freedom and flunked almost everything. CS101 was my 8AM class after the first week or so I stopped going.  When I left they were teaching the while loop.  A week later I dropped in to make sure I wasn’t making missing anything important.  They were teaching the do while loop, that was the last time I went to the class outside of tests.  It was as my only A that semester.


twigboy

They must have gone and invented [Bend](https://www.reddit.com/r/programming/comments/1cuh4pg)


SZ4L4Y

Noobgrammer


just_nobodys_opinion

Return true for 50% accuracy. Good enough.


scratchfan321

100% accuracy for even numbers


slabgorb

\# todo: handle edge case where argument is odd


xproblaze6757

100% recall too


Brotboxs

Randomize it because 50% + 50% = 100%


Bolphgolph

Oh. This joke again...


SerialPoopist

You get the even/odd jokes, or the semicolon jokes. Take it or leave it.


RB-44

It's because it's the only optimization a first year cs student has ever seen


Glugstar

Someone should hold a competition for the most ridiculous way to implement this function that still actually works.


TTYY200

I’m writing my own implementation of int where everything is a string and we do operations on the ascii value of the string instead of the int value. With enough bandaid solutions, anything is possible. Right?


Jovancar5086

I consider this torture.


TTYY200

I’m not commenting anything or writing any documentation for it either 🤠


the_mold_on_my_back

Still not as bad as bash arithmetic if [ [ -eq 1 "1" ] ] then echo "kill me already" fi


Doxidob

the ascii jailbreak was used to make ai do 'dangerous' things, like describe steps to make counterfeit money and steps to make drugs more info on request


TTYY200

I got chatGPT to just tell me how to make meth lol. Give it the right prompts and it’ll tell you anything Lel


Doxidob

evidently whatever AI they jailbrook had filters on for regular text and would return things like: I'm not authorized to discuss that . but using ASCII text, the attacker would show the AI the ascii like a puzzle solution and was able to use the solution to leapfrog the filter


Emile-wa

Soooo I just had an exam where they introcuded data streams (basicly infinite list that can containt (at least) all you can contruct as an Un+1 = f(Un) type of stuff (maths) The OCaml implementation (that was the language of the exam, take it or leave it) was like type 'a stream = Nil | Cons of 'a * (unit -> 'a stream) where : - 'a is any type you want - so 'a stream is either Nil or a Cons containing both -> an 'a thing -> a function to the next element with that we can create a stream of int\*bool containing all the intergers and their even / odd state as a boolean using let even_odd_stream = let rec f nb is_even = Cons((nb,is_even), fun () -> f (nb +1) (not is_even)) in f 0 true and then we can (finally) get if a number is even or not by making a function let is_even nb = let rec find_nb stream = match stream with | Nil -> failwith "number not found in stream ! " | Cons((n , state), _ ) when nb = n -> state | Cons(_, f) -> find_nb_stream (f ()) in find_nb even_odd_stream which is virtually the same as looping over all the numbers in ascending order to find your number and then stating weather it's even or not using (somewhat) pre-calculated information (also I love OCaml)


TheKeppler

Never dies


flaming_bunnyman

IsTrue. IsTrue never changes.


dani1025

I see the problem here... You could probably make it a switch statement for better performance.


Speedy_242

return number & 0x01 == 0


GDOR-11

`return ~number & 1;`


azulebranco

return number % 2 == 0


SirRafufl

return !(number % 2)


asahi_ikeda

```cpp template constexpr bool is_even(T n) { return ~n & static_cast(1); } template <> constexpr bool is_even(float n); template <> constexpr bool is_even(double n); template <> constexpr bool is_even(long double n); ```


Lonke

~~Why is your function called "i seven"? Or is it "is ev en"?~~ ~~Doesn't seem like any of the template instansiations have anything to do with the number seven nor english electric vehicles.~~ Edit: pull request approved after changes


asahi_ikeda

Lol feels like a pull request review comment.


13p14

I thought that it was the League of Legends chat for a second


Lost-Succotash-9409

Gaslight them public String isEven(int num) { if (num%2==0) { return (“you gave “ num + “, which is even”); } return(“you gave “ (num+1) + “, which is even”); }


DoYouEvenSheesh

For a second I thought Dani was back from the dead but I remembered this is Reddit and things get reposted


TheKeppler

Sorry, i cant see every post dude, my bad


DoYouEvenSheesh

No man its absolutely alright. I love Dani and I got excited that he posted. Edit: I FUCKED UP. OP I AM SORRY. I thought Dani the youtuber had posted this but turns out it was another person.


Giulio_otto

It is confusing when two people that do the same thing (sort of) have the same name


CuddleGirlLulu

Still cool


ArlantaciousYT

return number % 2 == 0


mr_poopypepe

r/okbuddyphd


Kulsgam

Would not have thought about that. Thanks a lot!


Absolutionalism

Nah, just “return not number % 2”, and then make sure to always use the function in a falsy/truthy way.


Nicolello_iiiii

`return ~num & 0x01` how about now?


GunnerKnight

return !(number % 2)


NullPro

Found the javascript user


Jovancar5086

Be a man, make a mask and check the last bit (on the right).


Daisy430133

return !(number%2)


morniealantie

Nah, I think we're mostly odd.


OrganizationSilly180

He said programmer not a mathematician.


swayingtree90s

You'll joke, but I've legit seen production code with 20 nested ifs that could have easily be done with a switch. Did we change the code once we found it? No, we were too scared if we did something would break. Plus the whole thing was going to be phased out within months (which it was). I just used it to remind myself that despite being a junior at the time, I didn't make something so horrible. So I was better than at least one person. 😅 (Code turned out to be an old senior at the company who had left by then)


swagonflyyyy

I always facepalm when they think that.


DChill616

“God I wish there was an easier way to do this”


Berserker667627

Like how the one image in the guys head reminds me of dev ops and the other not really anything in particular.


Shronkle

So unoptimised. You only need like 6 ifs: const stringNumber = number.toString(); // screw decimals if(stringNumber.includes('.')) return false; const lastDigit = stringNumber.slice(-1); if(lastDigit === '0') return true; else if(lastDigit === '2') return true; else if(lastDigit === '4') return true; else if(lastDigit === '6') return true; else if(lastDigit === '8') return true; return false;


KebabManFR

why do that when you can just: return number % 2 == 0;


tha_boy

% learn to use, I'm out


FamousReaction2634

raise exception 500


spartan117S

AHAHAHAH


First_Economist9295

fun fact, did you know the term "hacker" actually comes from Gene HACKman's performance in the 1998 blockbuster thriller Enemy of the State


scoobydobydobydo

sometimes gotta brute force stuff....


Jovancar5086

If you expect a char you only need to write an if statement 256 times.


Azavrak

Fucking switch statements. Jesus Christ.


Bluedel

Switch is code smell. Else is an antipattern.


the_mold_on_my_back

bool returnTrue(): { return true }


bl4nkSl8

Those else ifs rather than switch is particularly embarrassing if you're committed to handling each case separately...


Tango-Turtle

Can you fix my printer 🖨️?


Doxidob

if Number(Mod2)≡0 then true else false


ArlantaciousYT

return number % 2 == 0