Sunday, April 22, 2007

Reality Bites :-(

This weekend I spent a fair amount of time in solving the Ruby-Quiz for the week (#121). It appeared to me that I have really cracked a fundoo solution, till I checked some of the other solutions on the list. Looking at those solutions - my solution looks like a minnow. It probably simply means that I don't know the language well enough and have to work much more to get anywhere closer to others.. Never mind though..

There is a trick that I learnt this weekend -

Given a number N how do you find all permutations of N using numbers (1 and 2)

The answer is simple

1 = [[1]]

2 = [[1,1], [2]]

3 = [[1,1,1], [2,1], [1,2]]

4 = [[1,1,1,1], [2,1,1], [1,2,1], [1,1,2], [2,2]]

Got it?

No comments: