Programming exercise blog that posts a few programming problems each week, with solutions and reader comments in many languages.
HN commenters recommend it as a source of practice problems ranging from basic data structures to number theory, with solutions in the comments.
I also work at Google and what mystifies me when I do interviews is just how consistently people manage to screw up even the medium difficulty questions. I used to love asking this question until it was banned:
https://programmingpraxis.com/2012/01/20/knights-on-a-keypad/
This is a great question because it has several levels of solutions:
1. A recursive solution that iterates over all sequences, exponential time and logarithmic in space. Interviewing for T3 (entry level, think college grad), getting only this far in 45 minutes earns a "leaning no hire" in my book.
2. The above solution except with memoization, which reduces the runtime to linear but requires linear space. This one earns a "leaning hire" from me.
3. A dynamic programming solution that takes linear time and constant space. This one gets a "hire" to a "strong hire," depending on the elegance of the implementation and the strength of the discussion we have around it.
4. A logarithmic time solution involving adjacency matrices, matrix multiplication, and binary decomposition of numbers. I've never seen anyone get this and I only learned about it after months of asking this question.
It's shocking how few candidates actually got as far as solution 1. I kinda want to open this up to the HN comments section, because this does not strike me as a brutally difficult problem, but the rate at which people fell on their faces when presented with this question suggests either something about our interview process…
I think the difference becomes clear when you consider that a language syntax is not just source code. Raw, text source code is just the means by which humans express utilizing the syntax of the language. Once that source code file is tokenized and parsed, it's no longer tied to whatever that text was. It becomes an abstract object in memory that either represents a process (a series of machine instructions) or is fed to a process to be manipulated and processed (i.e. interpreted scripting languages).
For example, this blog post walks through McCarthy's original specification for Scheme: http://programmingpraxis.com/2011/11/01/rip-john-mccarthy/
apply[fn;x;a] =
[atom[fn] → [eq[fn;CAR] → caar[x];
eq[fn;CDR] → cdar[x];
eq[fn;CONS] → cons[car[x];cadr[x]];
eq[fn;ATOM] → atom[car[x]];
eq[fn;EQ] → eq[car[x];cadr[x]];
T → apply[eval[fn;a];x;a]];
eq[car[fn];LAMBDA] → eval[caddr[fn]; pairlis[cadr[fn];x;a]];
eq[car[fn];LABEL] → apply[caddr[fn];x;cons[cons[cadr[fn];caddr[fn]];a]]]
This is a type of source code. Notice it even includes non-ASCII characters. But this code isn't executable as it is. It has to first be translated into a program, somehow. See the first reply at the original link, which I will not reproduce here, for brevity.
It is a Scheme interpreter. The call to `evaluate` at the end of each test function is where the program gets…
Am I the only one here who finds the dailywtf sometimes extremely depressing?!
Take the stories with a huge grain of salt. Many people have complained about their stories being hugely exaggerated before being published.
Alex Papadimoulis (the author of the website) has also admitted in an email that he often makes up new stories by embellishing old ones. The email used to be on the following link, but now you must ask the Programming Praxis author for a copy. http://programmingpraxis.com/2009/08/13/the-daily-wtf-maliciously-infringes-programming-praxis-trademark/2/
Writing a brainfuck interpreter in a language is a good way to size it up. Unlike "hello world", it actually gives you a meaningful impression of how string handling, data structures, etc. work. It's not hard, but it's just enough to work up a sweat -- like a web-programmer writing a blogging engine or a wiki to try out a web framework. (If it is hard in the language, that should also tell you something.)
See also:
* Project Euler (http://projecteuler.net/), for math problems
* Programming Praxis (http://programmingpraxis.com/)
Currently in my RSS reader:
* Coding the Wheel - http://www.codingthewheel.com/
* Good Math, Bad Math - http://scienceblogs.com/goodmath/
* Gödel’s Lost Letter and P=NP - http://rjlipton.wordpress.com/
* Polymath Programmer - http://polymathprogrammer.com/
* The Endeavor - http://www.johndcook.com/blog/
* Programming Praxis - http://programmingpraxis.com/
* Pragmatic Bookshelf News - http://www.pragprog.com/news/
* Sutter's Mill - http://herbsutter.wordpress.com/
* Schneier on Security - http://www.schneier.com/blog/
1 Pick an Interesting Language
2 Learn the Syntax
3 Pick a Problem
4 Solve the Problem
5 Goto 3 if Done
6 Goto 1 after 1--2 Years
As for problems, http://rubyquiz.com/ and http://programmingpraxis.com/ are good starting resources.
To learn the syntax of a language, just search for the language and the word "tutorial". Pick a site and read through the material provided.
If you can't decide on a language, try:
http://www.ruby-doc.org/docs/ProgrammingRuby/
http://mislav.uniqpath.com/poignant-guide/