Posts

• ProTip: Poor man's pomodoro timer for Mac OS X

One Bash command for timing regular 25 minutes pomodoro session and one for 5 minutes breaks. Because, why use a fancy app or website when you can use an arcane piece of AppleScript in your beautiful Mac?

• First Non-Repeated Character For Each Prefix

For each non-empty prefix of a given string consisting of lowercase English letters, find the first non-repeated character if any.

• First Non-Repeated Character

For a given string consisting of lowercase English letters, find the first non-repeated character if any.

• Unique Substrings in Wraparound String

Given a strings s and p, find how many unique non-empty substrings of p appear in s.

• Tallest Trees

Given a list of people and a parent-child relation, find the tallest family trees.

• Corner to Corner Matrix Traversal

Given a square matrix of integers, find the maximum sum of elements on the way from the top-left cell to the bottom-right cell.

• Longest substring with at most k different characters

For a given string, find the length of the longest substring that contains at most k different characters.

• Substring with Concatenation of All Words

Given a string and a list of words of the same length, find all start indices in the string of concatenations of each word.

• Maximum Number of Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

• Number of Islands

A popular problem associated with Leetcode's online judge. Determine the count of islands in a grid of locations that are either land or water.

• Binary Tree Upside Down

A popular problem associated with Leetcode's online judge. You are given binary trees of a very particular form and you are asked to flip them upside down. A problem not too easy and not too hard.

• The Pattern Matching Problem

Find a match, any match. You will be given very simple patterns. But, how fast can you come up with a solution when you are not allowed to use your regexp library? And yes, you might find this in your next interview.

• 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 one-off 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 minitest-hooks is the way to go. For nested describe blocks, minitest-hooks may not behave as you want. This article provides two alternatives to minitest-hooks 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?