Humor Thread

Post CS grads

Other urls found in this thread:

imgur.com/a/lGOvs
boards.halfchan.org/g/thread/56718622/dpt-daily-programming-thread#p56720423
twitter.com/AnonBabble

That gets me

...

Here, go nuts:
imgur.com/a/lGOvs

public static boolean isPalindrome(String s) { if (s.length() == 0 || s.length() == 1) { return true; } else if (s.charAt(0) == ' ') { return isPalindrome(s.substring(1)); } else if (s.charAt(s.length()-1) == ' ') { return isPalindrome(s.substring(0,s.length()-2); } else if (s.charAt(0) == s.charAt(s.length()-1) { return isPalindrome(s.substring(1,s.length()-2); } else if (s.charAt(0) == s.charAt(s.length()-1) { return false; }}
I'll never forget this gem.

...

The memory leak is a nice touch.

Dumping

Goddamn 3 image limit

Fucking hell, uploading takes forever

...

here's a classic

...

float xxxxxxxx

It's graduates all the way down

Best one

I've been looking for that Windows 9 one forever, hahaha.

Proof that Holla Forums was always filled with scraps from other boards.

Holla Forums is the most shittiest board on this website nerd

Never said it wasn't, been saying that forever.

I was saying it first

truly the greatest post

what the fuck?

He found a way to make palindrome O(n^2). That's impressive in its own right.

That's fucking horrifying.

You're retarded.
That's still linear.

No, it's not. The first condition gets the length of the string, which depending on the implementation might very well take linear time because it has to traverse the entire string. This is especially true if the string uses a multibyte encoding where the number of characters is not the same as the number of bytes.

Every iteration is linear and there is a linear number of iterations (half the length of the string), so the algorithm has indeed square complexity.

The correct thing would have been to see if the string is empty (constant time) or if it isn't if the second character is 'NUL' (also constant time). If it's the latter the number of characters is odd, so that one middle character doesn't count for determining whether the string is a palindrome.

The isPalindrome method itself has O(N) behavior(worst case a string of ' ' removing one item each time). If you look it up, you'll find substring also has O(N) behavior.

...

Of course. It has to copy each character to a new string, which is N. It does that N times. O(N^2)

The length method may also be linear, but I doubt that. In terms of time complexity, that's irrelevant anyways.

This is universal among communities about technology or programming. They are always filled with hilariously incompetent shitters who think they are hot shit. I have no idea what causes it.

...

...

...

Competent people are probably programming or reading intelligently prepared materials rather than shitposting on Cambodian land mine clearing forums.

What's wrong with the Scheme wrong? Is it just the indentation?
t. CS grad

Pic #1 is the most horrible advice I have ever seen written. It is either intentionally poor or written by a designated street shitter.

Horribly inefficient, you want to use a square and multiply algorithm for exponentiation.

Doesn't use square&multiply, unnecessary helper function. It really isn't that bad when compared to other CS grad code.

It should be more like:

1) Read book, don't understand shit
2) Fuck with code
3) Read book again, understand some shit
4) Fuck with code again
5) Go back to 3 and repeat until you understand all the shit.
6) Make shitty "learn to code" comics and post them on Holla Forums

Googling shit you don't understand is a great way to get your time wasted by 100 different incompetents and street shitters on stack overflow doing a shit job at explaining how to do things in 100 different incorrect ways.

That's it? tbh I see that kind of thing all the time as a toy introduction to tail recursion.

There's a pretty massive difference between square and multiply and the naïve solution.

boards.halfchan.org/g/thread/56718622/dpt-daily-programming-thread#p56720423

Aye, but the goal isn't computational efficiency, it's pedagogy.

I humbly submit myself as a shitty cs (under)grad.

if(next_int > 0){/*add next_int to queue*/}
if(next_int >=0){/*add next_int to queue*/}

I'm not even mad, just happy it's over.

So you're paying tens of thousands of dollars to do hackerrank problems?

I'll take the fancy paper and student debt

You gonna need to solve hackerrank problems to get a job, degree or not. It's just funny that college has devolved to this.

Serious question: just how do I git gud enough to avoid this on my own? A lot of this reminds me of some of the shit I'd come up with. Do I just need to bite the bullet and go to college?

Sounds like the way Allen Jude describes how he wrote the FreeBSD bbootloader:

Some code I found at work:

if (empty($lastname)) { $scOwner = ' Owner: '.$owner.' TIN: '.$own_tin.' Address: '.$own_addr.' Telephone No: '.$own_tel.'   Administrator/Beneficial User: '.$admin.' TIN: '.$admin_tin.' Address: '.$admin_addr.' Phone No.: '.$admin_tel.' '; }else{ $scOwner = ' Owner: '.strtoupper($lastname).', '.$owner.' TIN: '.$own_tin.' Address: '.$own_addr.' Telephone No: '.$own_tel.'   Administrator/Beneficial User: '.$admin.' TIN: '.$admin_tin.' Address: '.$admin_addr.' Phone No.: '.$admin_tel.' '; }

Yeah college will teach you how to code as evidenced by this thread.

Read a lot of code by people who are better than you. Most great programmers were already great in high school.

It's a shockingly good strategy that most people aren't even aware of!

The String class has a variable that keeps track of the size of a string object.
So length doesn't traverse the whole string every time that the method is called.
It just returns the value of the aforementioned variable in O(1).


That's not exactly true.
Until Java 7 the substring method had O(1) complexity.
You might have a point for new version of Java but for older ones that function is definitely linear.

You need to read a data structures and algorithms text book.

Is The Algorithm Design Manual good? Seems like it, and also a bit less dense than CLRS.

I see that it gets good reviews, and if you like it then go for it, from a quick glance it seems great. Use that to get the basics and revisit CLRS later.

Seems worth the time. The first half goes over theory and the second has a catalog of algorithms for common problems. I've been meaning to actually spend time gitting gud at this for a while so I guess it's yet another book to start.

Yeah I went over the table of contents and I think it would be a good decision. The main thing you'll gain are new thinking patterns on how to better structure your solutions.

Then you'll by default be ahead of 99% of "web developers" who never bother to learn this material. Why? They can make stuff show up on the screen without it, so they don't find it necessary. Once they attempt something bigger, the end result is code like InfinityNext with O(n^3) loops all over the place.

I was asked to solve a graph problem once; having never worked with a fucking graph before I probably made a massive idiot out of myself. And never heard back obviously.

Looking at these makes me want to try getting more into programming. If I can recognize how shit these are with what little I've done something must have stuck.

I dowloaded that book to take a better look, and it's a really comfy read, so definitely a good place to start.

Also you might want to take a look at the book "Concrete Mathematics".

Yeah, I actually downloaded that one yesterday or the day before. Looks like its pretty much a must read especially with no formal background in CS.

Here's two other books you should look at afterwards.

The first is the best tome on AI, and in the first part they cover a lot of "classical AI" which is based on a lot of search problems. Amazing book, and becoming increasingly relevant as computer science is pulled in that direction.

The Sipser book is very nice for understanding parsers, classes of language grammars and complexity theory. Save it for later, but it should be a part of every computer science curriculum.

I'll add them to my reading queue. Might be a while before I get to them though.

Yeah, there's a lot out there to learn. That's why most legit programmers laugh at the idea of "outreach" programs to encourage women and underrepresented-minorities to casually get into computer science. You can't magically change some pronouns and make all the "scary books" go away.

Oh and, have fun.

Fun is a side effect :^)

Linear is O(N). Constant is O(1). I've never heard of substring being O(1).

Is this meant to be one of those embedded archives? I can't seem to extract it if that's the case, tried unrar 7z unzip

I'm feeling dizzy just by looking at this. Second and third checks can be completely omitted with String's trim() method, and third one should replace the fucking substring method with an index-based approach (what is method overloading for helper methods, you dumb currynigger) because HOLY FUCK WHY ARE YOU FUCKING ALLOCATING NEW STRINGS YOU RETARD.

It doesn't even work as intended. If 0 and length - 1 don't coincide, the method fucks its shit up and doesn't return anything, which is illegal in Java (compiler will refuse to complete if any method may not return something in some situation). How the fuck did they manage to make this compile?


For obvious reasons, the JVM never compiles all possible substrings for each String made, therefore it has to be O(n), n being the new string length.

No, sorry. It should be easy enough to find though.

Substrings don't have to be copied.

At least in the OpenJDK implementation, Strings don't come with a start and end index. In fact, substring() just copies the string to a new one with StringDecoder.

I'm interested in seeing your implementation of substring where this is the case.

Can't post pseudocode because it triggers the spam filter. Basically, you share buffers between a string and its substrings and keep track of the offset and length. Taking substrings is then equivalent to changing offset and length.

String s = "aaaaaaaaaaaaaaa";String t = s.substring(0);for (int i = 0; i < s.length(); i++) { t+= s.substring(i);}
You now have to have a list of (offset, length) to keep proper order of the string. I'll give it to you that you made .substring() O(1), but I'm confident you've increased the time complexity of every other string method. Even .length() would now be O(N) since you have to sum the length of each (offset, length) pair in the list.

I don't think you understand. A string is a triple consisting of a buffer, an offset, and a length. Obviously, length is still O(1) in this case. I'm not really sure what your code is supposed to prove, or in fact, what it is even supposed to do. Concatenation requires a new buffer, just like it would in the naive implementation.

I see, I was confusing two separate problems. It is definitely possible to have O(1) substring methods without messing with the time complexity of other string methods.