From: Jim Weirich Date: 2005-08-24T02:53:19+09:00 Subject: Re: [QUIZ] Sodoku Solver (#43) Adam Shelly said: > So here's one thing I couldn't figure out last night, maybe someone can > help me: > I wanted to throw an exception in the middle of a pair of recursive > functions, and catch it at the beginning of recursion. But I can't > figure out where to put the rescue. You could try something like this: def search_for_solution solve rescue UnsolvableBoard # Handle Unsolvable Boards ... end def solve while candidates do begin guess #chose a candidate cloneBoard.solve #with that candidate rescue BadGuess #go on to next candidate end end #while raise UnsolvableBoard if !solved end -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)