From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.unit0.net!cyclone01.ams2.highwinds-media.com!voer-me.highwinds-media.com!peer01.am1!peering.am1!peer01.fr7!news.highwinds-media.com!post01.fr7!fx07.fr7.POSTED!not-for-mail Message-ID: From: Mike H Reply-To: Mike Hopkins Newsgroups: comp.lang.ada Subject: Re: OT: A bit of Sudoku References: <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain;charset=us-ascii;format=flowed User-Agent: Turnpike/6.07-M (<8c+$+zb077Pti5diXa8NqJs7Yt>) NNTP-Posting-Host: 83.104.138.185 X-Complaints-To: abuse@demon.net X-Trace: 1401998902 83.104.138.185 (Thu, 05 Jun 2014 20:08:22 UTC) NNTP-Posting-Date: Thu, 05 Jun 2014 20:08:22 UTC Date: Thu, 5 Jun 2014 21:03:10 +0100 X-Received-Body-CRC: 4004641486 X-Received-Bytes: 3059 Xref: news.eternal-september.org comp.lang.ada:20151 Date: 2014-06-05T21:03:10+01:00 List-Id: In message <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com >Without seeing an actual program or any code at all, I can't really >tell, but ... when a caller calls itself recursively, isn't there >either a function result or an OUT parameter that allows the callee to >tell the caller whether it has succeeded? In which case the caller >simply exits, and returns to *its* caller passing back the correct >answer and if necessary a flag indicating that it's succeeded. I have >no idea whether I've identified the problem correctly, but it's the >best I can do without seeing any code. Anyway, I think that's the >general approach to handling backtracking problems. Thank you for giving me an alternative angle of view. The trial and error process is optimised by preselection of a matching pair of cells, they match in the sharing of a common pair of candidate solutions. By analogy, it is a choice of left or right. On average, 50% of trials will have explored both possibilities in which the first will have been wrong and the second will have proved to be correct. In the other 50%, the first choice will have been correct so the second choice is left dangling and unvisited.. I chose, perhaps wrongly, that the complete grid of 81 cells is passed down the recursion tree (as IN OUT). At each level, the grid is further completed as the full gamut of deterministic algorithms is exercised before either a lack of further success prompts a further trial and error attempt or a positive failure forces a return of up the tree. Thus, a return of control to a caller is taken as a positive signal of failure. But, currently, there is no equivalent positive indicator of success. I am beginning to think that a three-state flag is required (NO, MAYBE, YES). YES is not known until the 81st cell is solved. The job is now complete and control must now be passed back up the tree. What is different is that a YES would be a tangible way of contradicting the previous assumption that a return of control means failure. -- Mike Swim? Naturally at Severn Vale