Monday, May 20, 2024

Sweep them all off

I don't usually get a laugh from an algorithm, a pattern or procedure for getting something done.  But this article by Ben Brubaker was different.  "Why Computer Scientists Study Hard Problems" gave an example of an algorithm that has gotten a laugh from several people.  It is an algorithm for alphabetizing a shelf of books.  It works perfectly!


Check the shelf carefully to see if the books are in alphabetical order.  If they aren't, sweep them off the shelf onto the floor.  Replace the books onto the shelf.  Check to see if they are in alphabetical order.  If so, you are done!  If not, sweep the books onto the floor.  Replace the books onto the shelf.  Check to see if they are in alphabetical order.  If so, problem solved!  If not, sweep the books onto the floor…


Pretty smart, huh?

Popular Posts

Follow @olderkirby