home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky rec.games.chess:11833 rec.puzzles:8080 comp.unix.shell:5125
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!keele!nott-cs!piaggio!anw
- From: anw@maths.nott.ac.uk (Dr A. N. Walker)
- Newsgroups: rec.games.chess,rec.puzzles,comp.unix.shell
- Subject: Re: A puzzle for Christmas
- Message-ID: <1992Dec21.182336.14578@maths.nott.ac.uk>
- Date: 21 Dec 92 18:23:36 GMT
- References: <1992Dec18.200400.19070@maths.nott.ac.uk>
- Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker)
- Organization: Maths Dept., Nott'm Univ., UK.
- Lines: 55
-
- In article <1992Dec18.200400.19070@maths.nott.ac.uk> I wrote:
- >While at a conference recently, I picked up a neat little sliding-block
- >puzzle with a chess theme.
- [...]
- > If you want to construct [the solution] yourself, "unshar" the files
- >below into some unused directory, and type "run". [...]
- >While "run" is running, there is also a large database, which grows to
- >around 19 meg; this has to be sorted, so another 19 meg is needed, total
- >44+ meg.
-
- Thanks to Andy Walker, anw@maths.nott.ac.uk, for pointing out that
- this database and its sorted version are completely unnecessary, as I knew
- at one stage and had forgotten. In a sliding-block puzzle with a bipartite
- graph and in which all moves are reversible, those positions which are
- first reached in N moves are exactly those which are obtained by playing
- one move from those first reached in N-1 moves and stripping those which
- are first reached in N-2; there is no need to strip also those first
- reached in N-4, N-6, ....
-
- > On a Silicon Graphics workstation, the "run" script takes around
- >1h45m to complete;
-
- The revised version [below] runs in 13 minutes instead, and is
- probably fast enough even on a Sparc or a PC not to need re-coding in C;
- also, only 6M of storage, instead of 44M, is needed. Replace the version
- of "run" given in the original shell archive by the one below the "snip"
- line.
-
- --
- Andy Walker, Maths Dept., Nott'm Univ., UK.
- anw@maths.nott.ac.uk
-
- ====8<========8<========8<========8<========8<========8<========8<========8<===
-
- #! /bin/sh
-
- # This file is Copyright 1992 A. N. Walker, anw@maths.nott.ac.uk
- # Permission is hereby granted to use it freely for academic or
- # private purposes, provided that this notice is retained and any changes
- # noted in versions made available to other people.
-
- case $1 in
- [0-9]*) nn=$1 ;;
- *) echo kBWB:BWFW:KBDD:EWBW 1 D0 > l0 2> l-1
- nn=0
- esac
-
- nminus=`expr $nn - 1`
- while test -s l$nn
- do nplus=`expr $nn + 1`
- generate l$nn l$nminus l$nplus
- compress l$nminus
- nminus=$nn
- nn=$nplus
- done
-