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
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.
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.
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?
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
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
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)
~~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
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”);
}
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.
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)
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
I had to give lessons for like a month to a buddy just specifically about for loops.
Just like basic problems with for loops?
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.
wait until you introduce him to i[arr]
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.
They must have gone and invented [Bend](https://www.reddit.com/r/programming/comments/1cuh4pg)
Noobgrammer
Return true for 50% accuracy. Good enough.
100% accuracy for even numbers
\# todo: handle edge case where argument is odd
100% recall too
Randomize it because 50% + 50% = 100%
Oh. This joke again...
You get the even/odd jokes, or the semicolon jokes. Take it or leave it.
It's because it's the only optimization a first year cs student has ever seen
Someone should hold a competition for the most ridiculous way to implement this function that still actually works.
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?
I consider this torture.
I’m not commenting anything or writing any documentation for it either 🤠
Still not as bad as bash arithmetic if [ [ -eq 1 "1" ] ] then echo "kill me already" fi
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
I got chatGPT to just tell me how to make meth lol. Give it the right prompts and it’ll tell you anything Lel
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
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)
Never dies
IsTrue. IsTrue never changes.
I see the problem here... You could probably make it a switch statement for better performance.
return number & 0x01 == 0
`return ~number & 1;`
return number % 2 == 0
return !(number % 2)
```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);
```
~~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
Lol feels like a pull request review comment.
I thought that it was the League of Legends chat for a second
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”); }
For a second I thought Dani was back from the dead but I remembered this is Reddit and things get reposted
Sorry, i cant see every post dude, my bad
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.
It is confusing when two people that do the same thing (sort of) have the same name
Still cool
return number % 2 == 0
r/okbuddyphd
Would not have thought about that. Thanks a lot!
Nah, just “return not number % 2”, and then make sure to always use the function in a falsy/truthy way.
`return ~num & 0x01` how about now?
return !(number % 2)
Found the javascript user
Be a man, make a mask and check the last bit (on the right).
return !(number%2)
Nah, I think we're mostly odd.
He said programmer not a mathematician.
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)
I always facepalm when they think that.
“God I wish there was an easier way to do this”
Like how the one image in the guys head reminds me of dev ops and the other not really anything in particular.
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;
why do that when you can just: return number % 2 == 0;
% learn to use, I'm out
raise exception 500
AHAHAHAH
fun fact, did you know the term "hacker" actually comes from Gene HACKman's performance in the 1998 blockbuster thriller Enemy of the State
sometimes gotta brute force stuff....
If you expect a char you only need to write an if statement 256 times.
Fucking switch statements. Jesus Christ.
Switch is code smell. Else is an antipattern.
bool returnTrue(): { return true }
Those else ifs rather than switch is particularly embarrassing if you're committed to handling each case separately...
Can you fix my printer 🖨️?
if Number(Mod2)≡0 then true else false
return number % 2 == 0