Sunday, July 18th, 2010
I'd blogged previously about writing a python function to find out whether a linked list is acyclic or not - it's worth a read before tackling this one.
Problem: Given the head node of a cyclic (or circular) linked list, write a function to return the node that is at ...
Posted in programming | No Comments »
Sunday, June 6th, 2010
For a given time, what will be the angle between the hour and minute hands on a clock?
[ddet Answer]
This is rather a long winded way of solving this, so please let me know if you have something shorter.
The angle of the minute hand (from 12 O'clock):
= (minutes / 60) ...
Posted in puzzles | No Comments »
Sunday, April 11th, 2010
Let's say you need to find out the highest floor in a 100 story building from which you could safely drop an egg without it breaking. What's your strategy to minimize the maximum (worst case) number of drops you have to try?
If you just had one ...
Posted in puzzles | 2 Comments »
Saturday, April 10th, 2010
I want to revisit a probability puzzle from a previous post: see problem #5 in http://rebrained.com/?p=20
You play a game where you alternate tossing a coin with a friend, and the first person to toss heads wins. But let's make it a little more interesting by making the coin ...
Posted in puzzles | No Comments »
Friday, April 2nd, 2010
I read somewhere this is a Google interview question: Let's say you drop a stick, breaking it randomly in 2 places, leaving you with 3 smaller sticks. What's the probability you can make a triangle out of the 3 sticks?
[ddet Answer]
There are a number of ways to tackle this, including ...
Posted in puzzles | No Comments »
Thursday, June 19th, 2008
Let's say you're contracted to build roads to connect four towns that are at the corners of an imaginary square with sides 1 mile. What's the shortest length of road system you can build so that every town can get to every other town?
[ddet Answer]
The first answers that ...
Posted in puzzles | 4 Comments »
Saturday, June 14th, 2008
It's 3 O'Clock. What will be the time when the minute and hour hands are next in the same position (coincident)?
[expand title=Answer]
The Plodder's way: Let's start with the minute hand at the 12 and hour hand at the 3. Let's call x the number of minute ...
Posted in puzzles | 5 Comments »
Saturday, June 14th, 2008
A few more brainteasers..
Some of these are from Heard on the Street - a book of interview questions for Quants I'm trying to get through. Well worth a read if you're into this sort of thing...
1. Two ropes of different lengths, and you know that if you were to ...
Posted in puzzles | 2 Comments »
Thursday, June 12th, 2008
A collegue of mine was pondering the mthToLast problem for a LinkedList I'd blogged about previously and sent me the following IM message:
just a guess - but can you use recursion to solve your link list m problem?
a method to track through the list which calls itself,
then ...
Posted in programming | No Comments »
Thursday, June 12th, 2008
Very basic - take a string and reverse it using simple recursion. I'm sure there's a bunch of ways to do it, but like the fibonacci you should aim to be able to code something like the below in about 20 seconds...
>>> def reverse(str):
if len(str)==1:
...
Posted in programming | No Comments »