Posts

The Category Problem: graph traversal by recursive SQL queries
An interview question in the wild, the Category Problem asks to model a graph of categories of goods in SQL. The sample solution involves a couple of recursive SQL queries that traverse the edges of the model graph. The sample solution works in PostgreSQL 9.6. This post includes a reference implementation in Ruby.

The Stock Profit Problem
The Stock Profit Problem is an interview question you can find in the wild. The problem asks for the biggest profit given a sequence of stock prices. As usual, there is a naive solution that won't cut it. I explain an efficient solution in 6 different programming languages and give you a hint for further study.

Why use Planning Poker cards instead of saying your estimate out loud?
This article helps you understand why you really want to follow all steps of Planning Poker and use the right tools, specially when you run a distributed Scrum team. This article makes for a good reference that you can share with any team member.

The Special Offer Problem
A problem for the unsuspecting programmer. Makes for a great interview question.

ProTip: Automagically setup PhantomJS for Capybara+Poltergeist
This ProTip explains how to install PhantomJS automatically on program start. This way, running oneoff programs that exercise your web application becomes super easy.

How to do before(:all)/after(:all) in minitest
Minitest does not come with before(:all)/after(:all). For flat describe blocks, extension minitesthooks is the way to go. For nested describe blocks, minitesthooks may not behave as you want. This article provides two alternatives to minitesthooks for nested describe blocks and points to examples that you can run for 16 cases, 11 of them not covered here.

Correole: The minimum feature newsletter in Ruby
Correole is a minimum feature newsletter written in Ruby. Correole is ideal for a new blog when you just want to offer a minimal newsletter service. Correole plays nice with Heroku and only requires a confirmation page on the side of your blog.

Why does Heap's algorithm work?
Heap's algorithm for constructing all permutations is efficient and simple but not easy to understand. This article explains Heap's algorithm by example.

How to count cycles in a complete graph
An example of a question whose answer is an exponential function.

Arbitrage
Do you want to make easy money? Maybe currency trading is what you are looking for.

Release ActiveRecord connections in Sinatra + Thin
Are you experiencing database connection timeouts in your Sinatra + Thin + ActiveRecord application? Then you want to have a look at this.

Stacking Boxes
Finding a way to fit a given set of boxes one inside the other is easy even for more than 3 dimensions. Finding a way to fit those boxes by contorting them, not so.

Ecological Bin Packing
Group bottles with the least movements possible.

The Blocks Problem
Interpret a language of four commands to model the interaction of a robot arm with its environment. An exercise in keeping your solution simple.

The 3n + 1 Problem
A classical programming problem. The problem statement will tell you an answer, just not a fast one.

ProTip: Redirect stdout and stderr to console and different files in Bash
When you troubleshoot command execution, sometimes you need to analyze standard output and standard error side by side. Here is how to distribute output amongst multiple files and the console.

Jill Rides Again
Jill wants to know where to bike. Can you see past the straightforward solution to figure out the fastest solution possible?

The Captured Wise Men
Two wise men are prisoners in a tower in solitary confinement. Each holds half of an answer that would save their lives. Eventually, they put together the answer. But how?

The Adjacent Coins Problem
Choose a coin that maximizes your gain or minimizes your loss, but you have to do it in linear time and constant memory.