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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!buffer2.nntp.dca1.giganews.com!border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!medsec1.medien.uni-weimar.de!lucks From: Stefan.Lucks@uni-weimar.de Newsgroups: comp.lang.ada Subject: Re: OT: A bit of Sudoku Date: Fri, 6 Jun 2014 11:10:43 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com> <3d4f61d0-8f8f-49e9-a4ce-8fedffc5da10@googlegroups.com> NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-719578843-1402045843=:1469" X-Trace: pinkpiglet.scc.uni-weimar.de 1402045770 15950 141.54.178.228 (6 Jun 2014 09:09:30 GMT) X-Complaints-To: news@pinkpiglet.scc.uni-weimar.de NNTP-Posting-Date: Fri, 6 Jun 2014 09:09:30 +0000 (UTC) X-X-Sender: lucks@debian In-Reply-To: <3d4f61d0-8f8f-49e9-a4ce-8fedffc5da10@googlegroups.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) X-Original-Bytes: 3425 Xref: number.nntp.dca.giganews.com comp.lang.ada:186757 Date: 2014-06-06T11:10:43+02:00 List-Id: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-719578843-1402045843=:1469 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Thu, 5 Jun 2014, Adam Beneschan wrote: > My own experience with problems of this sort has been that passing the=20 > entire problem-state to the next level as an IN OUT parameter (or the=20 > equivalent, in other languages) makes life more difficult. It really depends on the problem you are trying to solve. > The callee needs to be able to make changes to the problem-state in=20 > order to try different possibilities; the caller needs the problem-state= =20 > to stay the same, so that if the callee returns without finding a=20 > solution, the caller can try the next thing on the problem-state it was= =20 > given as an input parameter. Right. So the callee *must* undo the change(s) it made, before returning=20 without a solution. If undoing is that trivial, then an in-out parameter=20 (or "global" variable declared in some outer scope) for the state is=20 reasonable. It may even be useful to transfer a solution found back to the= =20 callee (just don't undo the changes you made ...). As I understand for the Sudoku case, the entire change is to assign a=20 digit to an empty cell, and undoing means to turn the cell's state back to= =20 empty. If I am right, undoing changes is very easy, indeed! > The last time I wrote a Sudoku solver, Well, I have never written a Sudoku solver, but I did apply the=20 above approach to other backtracking problems, see, e.g.,=20 . BTW, a Sudoku-solver for Ada is still missing at Rosetta Code=20 . So long Stefan ------ I love the taste of Cryptanalysis in the morning! ------ --Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universit=E4t Weimar, Germany-- --8323329-719578843-1402045843=:1469--