Number System Solution

Yesterday I used a programming challenge to illustrate a use of generators. The solution to the problem given in that post was far from ideal – just a brute force hack, really. Today, let’s look at a respectable solution to the problem. Again, the problem: Imagine you are given a set of weights, each weight…

When Generators Are Brute Force Enablers

An interesting (if mysterious) programming challenge popped up in my business partner’s browser the other day. You’re given an odd set of weights which represents the series of powers of three. So, the first one is 1lb, the second 3lbs, the third 9lbs, the fourth 27lbs, etc. You also have a scale. If someone puts…

Duped by the Birthday Paradox

A well-known counterintuitive fact about probability is the birthday problem – the idea that the odds of two people in a group sharing a birthday increases much more rapidly with the size of the group than most people expect. Most people’s intuition seems to be roughly linear: odds increase more or less uniformly with each…

Clever Grouping in Python

Sometimes when you run across clever code, you just wanna tell someone about it. I spent about 5min. today trying to figure out the grouper function from the Python itertools recipes – because I needed to do something where I split a string, group the resulting list into pairs, and then build a dict from…

Making pyenv play with PySide on Mac OS X

So, I’ve been working a bit on my password manager (now called Stempel), and it’s working pretty well with CouchDB and a commandline interface, and it’s about time to make a GUI for certain purposes. I’d mentioned before wanting to use PySide for this purpose, and naturally PySide turns out to be one of those…

PySide Up and Running in OS X Lion

At the moment, I store all my passwords in text files which I manage with Vim. This is, of course, a horrible idea. It’s true that I name the files cryptically, so anyone who stole my laptop would probably take a long time figuring out what they were, but there’s still really no excuse. It’s…