Found in 16 comments on Hacker News
pixelmonkey · 2020-03-29 · Original thread
This question is not the same as -- but has a similar feel to -- the first programming problem in the classic book "Programming Pearls"[1]. You can read it on O'Reilly Safari these days[2].

Even if you don't read the book, that first chapter, "Cracking the Oyster", is worth a read. It's a fun problem.



johan_larson · 2016-07-11 · Original thread
Take heart. The interview process is designed to say no. A common anecdote at Google goes like this: "I persuaded the best programmer I know to apply at Google. And we rejected him." These companies say no to all kinds of talented people every day.

Apply again next time you are looking for a job, if Amazon and Google really are the sort of companies you want to work for.

Think back on your interviews and figure out what you did wrong, then study up on that.

And next time, prepare very carefully, with a focus on algorithms and data structures. I would use this book, although it's a bit dated now:

This one may also be useful:

a3n · 2015-04-27 · Original thread

The classic Programming Pearls is not exactly a book of problems, but a book of ideas.

You can probably examine a few of the ideas and play with them like toys. Toys are more fun than problems.

rb2k_ · 2015-02-13 · Original thread
I can recommend "Programming Pearls":

It hasn't a lot of algorithms per se, but it has a lot of examples of how a different view on a problem can lead to an easier/more performant solution. It also does a good job at explaining tradeoffs. I think it's great for people that have had some basic introduction already.

[Ref link if anyone feels like it:]

chollida1 · 2014-10-19 · Original thread
For those of you who aren't familiar with the author's other works, it's worth taking a peek at his other books.

I can whole heatedly recommend Pearls of Functional Algorithm Design

It's a good cross between two other excellent books:

- Jon Bentley's Programming Pearls


- Chris Okasaki's Purely Function Data Structures

If you haven't read all three, its well worth your while to do so!

And of course if you are going down the rabbit hole of reading Perls of Functional Algorithm Design then you need to read the "how to read Pearls of Functional Algorithm design" as well.

m_ke · 2013-09-01 · Original thread
Try Skiena's "Algorithm Design Manual" [0]. Another nice book would be "Programming Pearls" [1].

[0] [1]

brg · 2012-11-26 · Original thread
There are a number of programming books that I use to prepare for technical interviews. These are

1. Programming pearls,

2. Effective C++,

3. Programming Problems,

The reason for these texts is not because they are overtly insightful or well written, it is because they have a large number of problems with completely coded solutions. After working through these basics, programming interviews are much more enjoyable.

mmetzger · 2012-02-20 · Original thread
In fairness, Programming Pearls is a fairly well known, well regarded book-

Nertim · 2011-09-19 · Original thread
If you have time, get Programming Pearls by Jon Bentley (
adestefan · 2011-08-07 · Original thread
Programming Pearls is another excellent book in this realm.

Revisor · 2011-06-08 · Original thread
Thank you for your answers. To add something myself, the book Programming Pearls contains exactly this - short, elegant solutions, plus some extra food for thought and exercises.

vivekamn · 2009-05-23 · Original thread
Solutions in Programming Pearls. Each solution is iteratively improved with the proper reasoning.

kqr2 · 2008-09-16 · Original thread
The bibliography link in the original article was unfortunately broken.

Bentley is also well known for his book "Programming Pearls." The 2nd edition is still in print.

Fresh book recommendations delivered straight to your inbox every Thursday.