From: Mark Date: 2006-01-02T05:04:38+09:00 Subject: Re: [SOLUTION] Numeric Maze (#60) Nevermind, a copy and paste error on my part! On 1/1/06, Maurice Codik wrote: > Mark: could you explain what you mean? these were outputs from that prog: > > solve(3,1233): > [3, 6, 8, 16, 18, 36, 38, 76, 152, 154, 308, 616, 1232, 2464, 2466, 1233] > solve(1,25): > [1, 3, 6, 12, 24, 48, 50, 25] > > looks like it finds them just fine... or do u mean that these arent the > optimal paths? > > James: Now that I think about it, your optimization and mine are almost > equivalent, I think-- I'm fairly certain that the only way to get to a > number that you've been to already is by using consecutive pairs of > double/half.. since the add_two operation isn't invertable in this quiz. > > Maurice > > On 1/1/06, Mark wrote: > > > > Maurice, > > > > I just noticed that your solution can't find the path between two odd > > numbers. > > > > - Mark > > > > On 1/1/06, Maurice Codik wrote: > > > I guess we're allowed to submit solutions now... here's my first ever > > ruby > > > quiz solution (these quizzes are a great idea, btw): > > > > > > It's is an iterated-depth DFS w/ memoization written in a functional > > style > > > for fun. > > > > > > It exploits the fact that the optimal path through the maze will never > > have > > > consecutive double/halves, which reduces the avg branching factor of the > > > search tree to ~2. Keeping track of this state makes the code a little > > > uglier, but faster on the longer searches. > > > > > > Maurice > > > > > >