The Pitfalls of Software Complexity, Part [NaN]

Let’s say you’re writing code to print out three 3D shapes: a cube, a cylinder and a cone. You test it. Each one takes a few minutes to print, all look good. Ship it! A few days later, you get a bug report. Once every so often, a rounded cube comes out.

Well, you know more or less where to look. The problem must be in the cube code, right? You find the issue, fix it, go home. Leave the program printing cubes all night. The next morning look fine and sharp. You build a nice stack of cubes in your cubicle, all is good again.

A week later you get a change request: now objects need to come out in three sizes: small, medium and large. No problem, you implement it. Now you can produce nine different objects. Everything works fine, the customer is happy. Obviously the next thing they want is colors. Oh, and densities. Let’s say you compromise on providing four colors: blue, red, yellow, black. And density can be 1 to 5. Fantastic, now your code can create 3 x 3 x 4 x 5 = 180 different objects. It could be a large yellow cylinder of density 5, or a small black cube of density 2. Lots of things!

A couple of weeks go by. Your manager comes in with a puzzled look on his face, and tells you that some people have been reporting donut shaped objects once in a while. Sometimes they are green. Out of hundreds of thousands of objects printed the vast majority have been fine, but there are at least twenty of these (mostly green but sometimes orange) donuts out there. Of course you cannot reproduce this bug, because it would take you weeks of nonstop printing to encounter one of these cases on average. You have to dive into the code.

You start finding some weird edge cases. Sometimes a cylinder could become a donut, but only if the density happens to be in a certain range. But green? What’s up with that? How do densities change colors?

After two weeks and -14 pots of coffee [uint8_t coffee_pot_counter treated as signed] you think you’ve found the issue but you can’t be 100% sure. You test as much as you can, after one thousand prints no weird objects show up. Of course that doesn’t mean much. By the time you’re reading to ship what you believe is the fix, there is a new feature request: multicolor patterns!

You ragequit. A new guy gets your job. He looks at your code and has no idea what’s going on. He starts rewriting it from scratch.

A new requirement comes in. Now the customer wants different materials. And also a “shape morph feature.” Your ex-manager and your replacement can’t agree on how to implement the feature, or what exactly it should do, so they have a conference call with the client. The client says “well, the math is super simple. Take two shapes, for every cubic pixel in the intersection compute the average of the properties of the two and print that!”

In the meantime, you went off and started your own company. You now print exactly one object: a ball. It’s orange, and it has a unique texture. Customers love it; it’s happy, it’s fun. You sell a million of them. Some people want different colors and sizes, you say no. Some of them buy yours as is anyway, some wait for your former employer’s announcement of a bug-free orange ball any day now.

Do not taunt happy fun software complexity!

From Zero to Building and Flying Drones in a Month

On October 21st I bought this at a Toys “R” Us because it was on sale for $25. If you have never flown a quadcopter and have the money to spare, I suggest that you buy one right now (today I’d recommend this one instead, it’s more stable and much better outdoors). At first I could barely get it to hover in place. I crashed it countless times until it stopped working, so I bought another one. I was fascinated by the fact that this tiny thing can take off vertically (even from my hand), hold its position in space, and also move really fast in any direction.

I had an intuition for how quad rotors fly (watch this video for a beginner-friendly explanation) but I wanted to learn more about the technology. As a teenager I’d had a brief period of playing with remote-controlled planes and boats, which back then used combustion engines. Batteries had terrible power/weight ratios so electric motors were rare for flying things. Having precise control over four combustion engines pointing upward would have been difficult, so that’s perhaps why quadcopters didn’t get popular until Lithium polymer batteries (LiPo) became affordable to hobbyists. I started checking out the multiple subreddits dedicated to multicopters, quadcopter specifically, and diy drones. I quickly learned the following things:

  • There are two kinds of quadcopters: toys and hobby/pro ones. The first kind are very cheap (typically $20 to $100 ready to fly), come with their own proprietary transmitters, often have a camera. They are generally fragile and mostly harmless because they are very light.
  • Non-toy quadcopters can be further split into two categories: ready-to-fly and DIY. The most popular one in the first category is probably the DJI Phantom in its various models starting at around $500. These copters are for people who are mostly interested in aerial cinematography. They are very easy to fly: they come with GPS and know to hold their position in the sky like a cursor on a screen. You don’t get turned around flying them, even if they rotate the sticks continue to move them in directions relative to their original heading by default. They often have a function to come home when they are running low on battery.
  • DIY multicopters are significantly more involved. First you have to decide what kind of aircraft you’d like to build. One of the most popular kinds is the 250 (distance in millimeters between diagonal motor shafts). It’s very fast, so typically people use them for FPV racing/freestyle or acrobatics (watch those videos).
  • Most people start flying LOS (line-of-sight) as opposed to FPV (first-person-view) because FPV gear is not cheap. Some pilots who are used to the videogame-like dynamics of FPV don’t know how to fly LOS.

Having said all that, an actual drone is something that flies itself. If it has a human pilot, technically it’s not a drone. This week I’m in the process of building a proper drone; I started with a cheap 360mm quadcopter using parts from HobbyKing as described here. I’m replacing the controller by an APM with a GPS/compass module ($70 for both). This hardware supports Mission Planner, which lets you program the aircraft to go do something you want. My next goal is to have it take off, move a short distance, hover for a few seconds, and come back to land where it started.

Also, last week I finished building a 250 “racer” quad with FPV capability that I’ve flown a few times. I’m relatively confident at LOS flying, but FPV seems much harder to me.

This is me flying LOS:

And FPV:


Why We Hate Ads

If you are aware that you want to find something, you search for it. There was a time when searching wasn’t easy, so you had to rely on your memory cache of known things. You could argue that ads were useful in filling that cache, particularly for things that you had not needed or experienced up to that point. Now that we have instant online search, that problem is no more.

Sometimes you’re unaware that you want to find something, but you’d be pleasantly surprised if a genie told you “here’s what you didn’t realize you wanted.” That’s what predictive search is about. A perfect predictive search agent would either shut up (perhaps most of the time) or give you extremely relevant results in anticipation of a query that you haven’t articulated yet. Unfortunately, online ads are not that genie. If that were their purpose, we could say that irrelevant ads are a poor implementation of predictive search.

Some argue that with better ad technologies there will be fewer mismatched ads: it will become easier to match products to consumers at the right time. That assumes that every product for sale can be matched to a consumer at a given point in time. Why should that be true? One of the uses of advertising is discovering whether people are interested in a product or service. Suppose a chef from a different galaxy came to our planet and opened a restaurant. Not being sure of the tastes of humans, he starts with his three favorite items on the menu: fish, steak, and uranium. It won’t take our alien restaurateur very long to figure out which item he should stop offering. There may be large numbers of things advertised that nobody cares for; a product genie would immediately tell the advertiser “don’t waste your money, I’ve analyzed humanity and nobody in their right mind wants this.”

Because that product genie does not exist, advertising will continue to be a mechanism for (in)validation of products for the foreseeable future. As a result, we will continue to see ads that we’ll perceive as annoying or irrelevant. No product-consumer matching technology should try to find hungry people interested in ingesting uranium.

Startups Compete Against Background Noise

The traditional competition between companies has been about the price and quality of their products. For most startups that haven’t reached product-market fit, that shouldn’t be a real concern. As Justin Kan puts it:

But why and how do startups compete against no one giving a shit? For one, starting a company has never been easier so there are lots of them. “I am the founder of a startup” says little about a random person you meet in Silicon Valley. Imagine that Wimbledon expanded from 128 to 65,536 players. More people would be able to say “I played at Wimbledon” but the average participant would not have a sponsor or be able to make a living as a tennis player. As this “Wimbledon expansion” slowly took place, the traditional competition moved to a later stage. In the beginning, startups compete against other businesses in areas such as:

  • attention. Because there are more products and services that ever before, there is a significant chance that nobody will learn about what you’re doing. In that sense they don’t compete just against other startups or large companies; they compete with the background noise of the online world that all of us generate.
  • employees. If your startup makes backup cameras for bicycles (“parallel parking your bike is now easier than ever with BikeSeatCam!“), you want to hire the people lots of other companies in completely unrelated markets also look after.
  • funding. That’s perhaps the closest thing to a startup league competition. Investors must decide where to put their money, and often choose among startups that are unaware of each other’s existence. Still, this is the fiercest competition most startups will face. You can study the weaknesses of a specific opponent and perhaps exploit them, but when competing against the faceless crowd there are no shortcuts: you must be significantly better than most.
  • customers. That comes after surviving the other types of competition long enough to have a product out in a validated market. Most startups will never have the luxury of reaching this stage.

Many founders I’ve met have a hard time understanding the nature of this competition, and adjusting their thinking to compete in those terms. For example:

  • Getting attention is an art, and many underestimate how important it is. If you’re doing something wacky (“our drones keep your cellphone in front of your face so you can watch Netflix while you jog outside!”) or controversial (e.g. Peeple this week), attention comes more easily. If your product is relatively boring, you’ll have to figure out how to get the attention you need.
  • Attracting employees is a multidimensional task: some people are lured by the promise of working with known industry figures, some want to take on a sexy project, others value the potential of the business. What you have to do to attract the right employees may be unrelated with the nature of your business. For example, your customers may not care at all about your software stack but your potential employees will obviously prefer some tools over others. Is there anything that makes your company a unique place to work?
  • Fundraising is literally selling. A startup is selling a part of itself in exchange for funds to operate. Investors are people who buy investments in the same way that consumers buy daily necessities. Even though this is obvious, I keep meeting startup founders who believe that investors are like their rich uncles. In reality, investors are more like shoppers in a giant grocery store filled with unknown stuff: should I buy some gluten-free Twitter substitute or try the “I can’t believe it’s not Uber” instead?

If you’re reading this post you’ve probably heard the YCombinator mantra “make something people want.” Even though it has a zen-like air of wisdom, I find it as actionable as “score more points than your opponent.” There are countless reasons making something people want is really hard. One of them is that if you startup cannot rise above the background noise and get the right amount of attention, it will never find out if it’s on the right track. For startups, loudness is a virtue.

Failure Criteria for Startups

In Silicon Valley a startup is a vehicle for performing an experiment. The motivation is usually a hypothesis of the form:

If we build and promote this product/service correctly and with the right timing, we will generate a scalable business that will significantly change an existing market or create a new one.

Once a startup has succeeded, it’s possible to construct a narrative showing how the hypothetical assumptions played out as the founders had hoped. For unsuccessful startups, it’s frequently the case that the experiment runs out of funding before the hypothesis has been fully put to the test. The participation of investors adds an implicit constraint to the experiment:

It’s possible to carry this out in stages of funding. The first stage requires $X, and will reach milestone M within T months.

Of course, experiments can and do fail before the money runs out. When this happens, it’s rare that founders acknowledge it and return the remaining funds to investors. Most often, failed startups linger on until they run out of cash. If you’re in Silicon Valley, I bet you already have an example in mind. If you’re not, know that many companies you’ve read about on Techcrunch are ghost ships. Long written off by their investors, they fly on autopilot like Payne Stewart’s jet. They may show signs of life once in a while because employees have to do something (“we just added wings to this boat because we like wings, it probably won’t fly but I’ll write a blog post about how pretty it looks“). Unlike human beings, companies tend to look healthy to outsiders even (and perhaps especially) when they are hopeless.

In my view, this is the worst possible failure mode for the founders. They often spend the remaining funding on keeping the startup alive for as long as possible. Sometimes they downsize, take pay cuts, and stretch the funding to last for years. This behavior is fueled by biases such as the IKEA Effect (people place an irrationally high value on what they have created), or the reluctance to accept that the effort spent thus far (sunk cost) has yielded little value. Some of these startups find metaphorical soft landings, but a startup is less like a physical aircraft and more like an expensive flight simulator.

When I was running my last startup I tried to avoid the above scenario. During the fundraising process I wrote down where I’d need the company to be at certain points in the future in order to want to go on. I saw this as a sort of contract with myself. Lucky for me, we always reached our goals (not always with much room to spare, of course) and were doing well when we were acquired. After that I tried other self-funded experiments by myself, for which I did the same thing. The latest of them was Cointipping, an app for sending small amounts of Dogecoin. I started it in early 2014, and I abandoned after a few months without thinking twice about it.

If I were to start a company today, I’d formalize the process. I’d have a set of minimum goals to accomplish in six months, and a tentative set for six months after that. If when the six months have passed I haven’t reached my goals, I’d fire myself. Otherwise I’d evaluate the next set of goals to see if it still makes sense and adjust it accordingly. Repeat until the company has reached momentum or died trying.

Final thought: this kind of self-imposed accountability is what most politicians abhor: when you’re not motivated to fulfill your promises but you want to keep your job, you do not want to be evaluated based on the results. However, a startup is not about staying in power. It is (to me, at least) about having a realistic chance of building something at scale. There are unlimited ways to do it, and no need to hold on to a particular one because “hey, we still have seven months of runway. Let’s pivot into something that won’t piss off our investors even though we’re not really excited about it.”

I leave you with an episode of the British TV show “Yes, Minister” that inspired this post (the relevant part starts around 5:40).

College Is (Almost) Obsolete

A few days ago a neighbor in her eighties offered me a piece of advice regarding my six-month old son: “start a college fund.” For some reason it sounded to me as if she’d told me there’s a great future in plastics. I have no intention of starting a college fund for my son, and this post is an attempt to explain why.

When I entered the workforce in the early nineties I had only one tool to increase my chances of getting the job I wanted: my resume. Looking for a job worked like this:

  • scan the job ad section of the newspaper
  • choose a few interesting positions
  • make copies of my resume and try to get them to the right people
  • wait for a call

Some time later when I was on the recruiting side, finding the right person was a costly task. I started with a pile of resumes but only had time for two or three interviews per week; I had to pick promising candidates based on the little signal I had. This was a time before Facebook, LinkedIn or Google; all the information I could reasonably obtain from applicants was in those pieces of paper. Most of us believed that resumes had a high chance of containing lies, because most claims were unverifiable. Probably the easiest ones to verify were someone’s degree and GPA, so we believed that people would have less of an incentive to make those up. For that reason we prioritized candidates from the best schools and with the best grades (assuming their resumes didn’t contain negative signals such as horrendous grammar).

Over the course of the next decade (and especially in the software industry) this started to change. First, people became searchable. The best software developeres often had a web page or some online trace of their work. LinkedIn slowly started making resumes irrelevant: the chances of being found out are much higher if you lie on your LinkedIn page. GitHub made it much easier to know if someone can write code.

When I look for software developers today and want to decide whether someone is worth meeting, the college signal has a tiny influence compared to everything else. As I said four years ago, I probably won’t interview someone who doesn’t have a LinkedIn profile and a GitHub account with some activity. I do not think the college signal is worthless though: to me, being able to stick with at least four years of structured coursework and tests is an indicator of consistency, discipline, and a certain type of intelligence.

If someone asks me the question “I want to become a professional software developer. With that objective, is college worth the investment?” my answer is no. This is one of the reasons I became involved with Platzi: it that’s your goal, it gives you a much better ROI.

Of course there are other fields for which a formal education and certification is still important (medicine is the most obvious one). Also, there are other reasons to go to college besides increasing your value as a worker: it’s a life experience, a good way to meet like-minded people, and it provides a good place to learn from others (of course not the only place or even the best, as was the case before the internet). Unfortunately I do not believe those reasons justify the cost of college in the US for someone who’s not quite wealthy. I’m sure the deans of Ivy League universities would entertain a different opinion, given that the future of their industry depends on the perceived value of their services. What they won’t say is that the commoditization of degrees caused by the expansion of their business means that having one is no longer the differentiator it was one or two generations ago.

In conclusion, I don’t think it will be indispensable for my son to pay hundreds of thousands of dollars to become a successful professional. He may choose to do so if he wants to enter a field requiring access to expensive laboratory equipment, or one requiring legal certification monopolized by universities. However, there’s a growing list of professions that will employ smart and resourceful people regardless of where or how they acquired their skills.

The Investors You Want

Next week 114 startups will be presenting at the YCombinator Demo Days. That’s a huge number; I’ve been looking into some of them and it’s overwhelming. To me, incubator demo days bring to mind the Hunger Games: a number of extremely driven founders compete for investor attention and money over the course of a few hours. Interestingly this is more like a real game: nobody will die (hopefully), and there are multiple chances to participate in it. If I were playing, I’d focus on maximizing my chances of getting the ideal investors for my company. So who are those ideal investors?

Let’s use the following definition: an investor is someone who gives you money in exchange for ownership in your company. By that definition, the minimum value from an investor is the amount of money he/she contributes. Obviously it’s possible to get much more out of an investor. These are my criteria for choosing:

  • All else being equal, pick someone who was a funded entrepreneur once. You can’t be a teacher without having been a student. You can’t become a pilot if you haven’t been a passenger first. If I had to pick between two investors, I’d prefer the one who was in my shoes once. There are a number of reasons beyond empathy. If nothing else, this person must have faced some of the problems you are having or will have.
  • Have at least one investor who’s well connected in your target market or industry. I’d be very skeptical of a medical startup who had zero doctors as investors, for example. So many rich doctors in the US and you couldn’t convince one to invest? Do you at the very least have an investor who’s a respectable healthcare industry insider? Besides the credibility, having someone motivated to introduce you to their peers can be extremely valuable.
  • For some startups, an investor with a megaphone is essential. Of course, there are different types of megaphones. A large following on Twitter is an obvious one, but there are others. In certain niches some people have loud voices that don’t translate into thousands of social media followers. On the other hand, having a celebrity with a million followers as an investor may not give you the attention you need. The more of an introverted nerd you are, the more you need others with a vested interest in helping you promote your product or service.
  • An investor with no time for you might as well be just money. Suppose you have the ideal investor with all the previous properties, but he/she never replies to your emails. This is more common than you’d think. Some successful people have too many investments and too little time. One of the traits of (what I consider) good investors is that they know when they can be helpful. When I reached out to my IndexTank investors with specific asks, they always stepped up. How do you know if this will be the case? Ask their portfolio companies. They perform their due diligence on you, and of course you must do the same. When I was raising money for IndexTank and things were heating up, we got substantial interest from desirable investors that I’d never met in person. If I was inclined to let someone into the round, I made up a rule: I’d have to meet in person and chat for a while before taking their money. That meant many hours of driving in the Bay Area, but it was worth it.

The corollary of this is that a desirable startup is the one that has choices. If you can’t convince the investors your company needs, that’s a problem you need to solve first. Picking undesirable investors just because they are the only ones who want you is the same as marrying the first person who’ll say yes. I won’t tell you how to make your company attractive, at the very least you’d have to buy me coffee 🙂

Also keep in mind that the odds are never in your favor. It wouldn’t be fun if they were.

Pre-startup Advice

It occurred to me that trying to give startup advice to a founder is somewhat like coaching a marathon runner during the race: it’s not completely useless, but you’d want to start months or years earlier. Of course, as an investor you don’t have that luxury; you typically meet founders at mile 2 or 3 (e.g. YC, AngelList, demo days). This why there are so many startup advice posts by investors. I find it more interesting to think about those who want to start a startup, and who believe they’re ready for it. These are a few questions that I’d want a potential founder to ask him/herself:

  • Are you extremely competitive? The Silicon Valley startup ecosystem is about extreme competition. You will be competing for funding of course: an investor has limited money and attention. You’ll be competing for talent, press coverage and obviously for users/customers/eyeballs. And often it’s not a “you win some, you lose some” situation. For example, funding is usually “you lose lots, maybe you win one.”
  • Do you like selling? The above activities are not about building, they are about convincing others to give you something (money, resources, time, attention). If you like to build things but are terrible at selling, you’ll be competing against the best. It won’t be a fair fight.
  • Have you ever stuck with a multi-year goal despite unfavorable odds? Things like college obviously don’t count, because they are designed for your success. What does? Perhaps having worked thousands hours to get really good at something, especially if you didn’t seem particularly talented at it (a sport, a musical instrument).
  • Are you ok with doing mundane/boring stuff most of the time? Building a business is mostly boring work. Writing code is usually not boring (if you like it), but if you’re doing things right you won’t be coding for long. Or building hardware, or designing, or whatever. You’ll be attracting employees, keeping them excited, figuring out how to make money flow into your company (both through sales and investments). You’ll be dealing with lawyers, landlords, service providers. Giving presentations, tweeting, perhaps writing articles and/or interacting with the media. Your involvement with your product will decrease over time; if you really like product development (think Steve Jobs) you’ll either neglect other tasks or do it in your “free time.”

If not one of the potential founders is extremely competitive, I’d say don’t even bother. You’ll get crushed. If you’re lucky it will be quick and obvious, if not you won’t even know it for some time. Maybe you can learn to be competitive, but I have my doubts.

If you don’t like selling, see if you can force yourself to do it for a while. At the very least you must be decent at it, and not hate it. If you can’t or won’t… good luck.

If you haven’t done anything really hard that took years, why is that? If you’ve given up on too many things, that’s a bad sign. If you’ve accomplished something significant but it did not seem that hard, you have hope. Be honest with yourself regarding your ability to deal with an adverse situation for a long period of time. This one is hard to predict, so you may have to take a risk and see.

Do you really, really like coding? As in, is it really important for you to get better at building things, to hone your craft? That’s something to overcome. Startups are about getting people to use your stuff and eventually paying you by any means necessary. Nobody cares if your service or product is powered by beautiful code, minimum-wage employees, magic or impeccably logical Vulcans. Many aspects of your company will be barely good enough because you’ll be operating at your limits. If your software (or in general whatever is under the hood) is too good, it probably means you are sacrificing aspects that you can’t afford. Worse, you don’t even know it because you don’t get feedback from users who don’t exist, or from investors who rolled their eyes after you left the room.

The reason most of us only hear about the interesting aspects of startups is obvious: they make for good entertainment. Boring, mundane work is not news. It is, however, what can make you a successful business person if you do it right and get lucky.

This clip never gets old. Founder life is sometimes like this, often much less exciting.

Random Partition of a Sequence

Here’s a mildly interesting puzzle: suppose you have an ordered sequence (e.g. the numbers 1 to 10). How would you randomly divide it into partitions such that any possible partition is equally likely? Your partitions can have anywhere between one and ten elements. One example partition could be [1 2 3 4] [5] [6 7] [8] [9 10].

Before I give you the solution, here are a couple of hints:

  • There are four possible partitions of three elements:
    [1] [2] [3]
    [1 2] [3]
    [1] [2 3]
    [1 2 3]
  • If you were to run your function a large number of times, you would expect each one of those to occur close to 25% of the time.

In Clojure, you could test your random partition function like this:

 (take 100000
       (repeatedly #(random-partition [1 2 3]))))

And if your function worked properly, you’d expect your output to look like:

{((1 2 3)) 24726, ((1) (2) (3)) 25049, 
((1) (2 3)) 25077, ((1 2) (3)) 25148}

A good way to look at this problem is to first calculate the number of possible partitions. If we think of the sequence as a piece of tape that we can cut, we realize that for three elements there are two places to cut. More generally, for N elements there are N-1 cutting points. At every point we can choose to cut or not to cut, which means that there are 2^(N-1) possible partitions.

With this in mind a straightforward solution to the problem is:

  • traverse the sequence from left to right
  • toss a coin at every cutting point
  • leave it alone if it’s heads, cut if it’s tails

Note that you don’t even need to know the length of the sequence in advance. In fact, you could start cutting an infinite sequence and grab the first few random pieces (i.e. stop after a certain number of tails).

Here’s my Clojure implementation of this algorithm:

(defn random-partition [xs]
   (when (seq xs)
     (loop [i 1]
       (if (zero? (rand-int 2))
         (recur (inc i))
         (let [[a b] (split-at i xs)]
           (cons a (random-partition b))))))))

And a much more concise one based on partition-by, courtesy of Gary Fredericks via the #clojure irc channel on Freenode:

(defn random-partition [xs]
  (partition-by (fn[_] (rand-nth [true false])) xs))

You can take 10 random pieces of the natural numbers with:

(take 10 (random-partition (range)))

and expect a result like:

((0) (1) (2) (3) (4 5 6 7) (8 9 10) (11 12) (13 14 15) (16 17) (18 19))

Please do not use this puzzle as an interview question 🙂

Life, the Universe and Technical Interviews

“There is a small satellite orbiting an unremarkable planet 50 light years from Earth. In spite of its tiny size, this floating cube of metal and silicon carries a load of paramount importance to the infrastructure of our galaxy. Inside its computer resides the Big Developer Matrix. As you can infer from its name it is fairly large, and it contains information about developers. More specifically software developers, because it was created by software developers. Each row of this matrix represents a company, and each column a developer. Every cell contains a binary value, which means either HIRE or DON’T HIRE.

The Big Matrix is rather sparse, and it is widely used by software managers across the Milky Way. In fact, it is the standard tool for hiring decisions pretty much everywhere. There are some fringe planets like Earth who rarely query the Big Matrix, and nobody is quite sure why. One of the maintainers of the software suspects it may have to do with a mismatch between the latency of communications and the average life spans of humans.”

— The author of this post, just now.

Unfortunately for us humans, we have little choice but to conduct technical interviews. We need an answer to the question of whether we want to hire someone or not, and we don’t have the time to really assess someone level of technical competence. Many try to approximate the Big Matrix with a series of progressive Bloom filters: techniques that tell you DON’T HIRE this person or INCONCLUSIVE. FizzBuzz is a good example of a Bloom filter question. I’ve never asked it to anyone and I don’t think I will; if you have to ask that question, you probably should rethink your pre-interview selection process.

One of the things I dislike about FizzBuzz is that it reminds me of customs forms with questions such as “have you ever been a member of the Communist party?” It’s almost insulting, and there is no way to show that you’re a good developer by coding FizzBuzz. There are questions that serve a similar purpose, while at the same time giving the candidate an opportunity to show off some skills. Here’s an example of a question that I like, even though I’ve never asked it:

Write some code that calculates how many numbers under a million (positive integers) have digits that add up to 42.

Why do I like this question? For one, it doesn’t require any specific knowledge besides basic programming techniques and math. Anybody who spent some time programming in some language should know enough to solve that in a few lines. Also, it has a mundane element that you normally encounter in real-life programming: one straightforward way of answering the question involves converting integers to strings and back. Furthermore, it lends itself to elegant functional solutions. Finally, getting the reference is an added bonus for personality fit 🙂

I asked this question on Twitter a couple of nights ago just for fun, and got some quick responses. The first one, in Haskell:

another one, in Python:



One of my favorites, in C and bash:

One I did in Clojure, without using strings and using recursion:

(count (filter #(= 42 %)
               (map (fn d [n]
                      (if (> 10 n)
                        (+ (mod n 10) (d (quot n 10)))))
                     (range 1e6))))

One in Forth by @technomancy:

s dup if 10 /mod recurse + then ; : f 0 1000000 0 do i s 42 = if 1 + then loop ;

I couldn’t fit a Java version into a tweet, but someone did it with Java 8:

class S{public static void main(String a[])
{int i=0,j=0;for(;i++<1e6;j+=(i+"").

@ejenk reduced the Haskell version to:

length . filter (== 42) . fmap sum . replicateM 6 $ [0..9]

There were a few other good solutions. The shortest were in languages like sed or Wolphram, which allowed the authors to “cheat” somewhat.


I will never get to ask the 42 question in an interview. If I did, I wouldn’t expect a candidate to show off code-colfing skills. I might ask about performance considerations for a larger space, and be pleasantly surprised if the candidate pondered solving the problem  mathematically for a second.

While this particular question may seem very easy in the comfort of your browser and favorite editor, it’s not trivial in the context of an interview. Always remember that technical interviews are very stressful; some of the best candidates I interviewed had sweaty palms upon entering the room. Even the best of us sometimes forget to bring a towel.