Randomness

Take a look at the following puzzle: “Given a function which produces a random integer from 1 to 5, write one that produces a random integer from 1 to 7″ I immediately thought of this: ... function naiveRand(){ return (given() + given()) % 7 + 1; } ... It is...

Read more

The Zoo problem

I just discovered TopCoder, and I got hooked. I’m going to post here some of of the easiest archived problems and their solutions (I’ll start with the hard ones later). This one is called simply “Zoo” and it is about a fox that wants to know if zoo’s rabbits are taller...

Read more

Hello Internet!

I finally got convinced of writing a blog, I’ve been solving some puzzles and small programming challenges, so I thought it would be better to write the answers and notes in a blog instead of keeping them under a dusty folder somewhere on my hard drive. Please feel free...

Read more