Sunday, July 17, 2011

Light bulbs in a circle

There are 2011 light bulbs in a circle. There is an uber switch that allows you to flip the state of any four consequtive bulbs at a time. Starting with a configuration with all bulbs off, can we end up with all bulbs on , by following a sequence of such flips?

Friday, July 15, 2011

Triangle

Consider a triangle with vertices labelled A,B and C.
We'd like to count the number of paths of a given length say n, that start and end at A.
The interesting part is that there is a closed form solution to this problem,
and whats more this solution can be implemented in two lines of Haskell code.


g = 0:1:zipWith (\x y -> 2*x + y) g (tail g)

f = [2*x | x <- tail(g)] 

eg, f !!6 = 86 (that is , there are 86 distinct paths of length 8 )

Thursday, November 11, 2010

Ubiquitous Fibonacci

Try this for size: Given a n digit binary number (ie, 0s and 1s only), how many such numbers
are there that do not have two consecutive zeros. eg: focusing on 2 digits, 01,10,11 are allowed but not 00

Sunday, October 31, 2010

A combinatorial dessert?

Last weekend, I was doing some QA testing when one of our interns from this summer messaged me with a problem she was solving. It turns out to have an elegant solution, and will be my first blog!
A group of friends and I have found that solving puzzles seems to remove some of the drudgery in our life, and keep the work day interesting. Whenever I find new puzzles/ or problems of interest, I plan to update this blog with them. It is also a way for me to keep track of all these problems.

So here goes: How many non decreasing sequences can you form with n digits?
For example, with two digits, we can have sequences like 00, 01, 11, 45, 66, etc that are non decreasing, while a sequence of the form 43 would be decreasing and would not count. For two digits, you can easily convince yourself that we have 55 non decreasing sequences. For general n, what is this number?

Note that I am counting 00, 01 etc as two digit numbers . If I were to count them as one digit numbers, then the answer would be slightly different.