home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.ai:3385 rec.puzzles:6091
- Path: sparky!uunet!usc!wupost!darwin.sura.net!mojo.eng.umd.edu!mimsy!mimsy.umd.edu!nau
- From: nau@frabjous.cs.umd.edu (Dana Nau)
- Newsgroups: comp.ai,rec.puzzles
- Subject: Re: How do I solve the 8/15... Puzzle (was (Is it connected))
- Message-ID: <NAU.92Sep8225007@frabjous.cs.umd.edu>
- Date: 9 Sep 92 02:50:07 GMT
- References: <babraham.3.715849833@unpcs1.cs.unp.ac.za> <1992Sep7.155720.19507@CSD-NewsHost.Stanford.EDU> <mgv.715889137@ash.cs.scarolina.edu> <1992Sep8.041003.17677@ctr.columbia.edu>
- Sender: news@mimsy.umd.edu
- Followup-To: comp.ai
- Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
- Lines: 41
-
-
- From: matthew@psych.psy.uq.oz.au (Matthew McDonald)
- Newsgroups: comp.ai,rec.puzzles
- Date: 8 Sep 92 04:10:03 GMT
- Organization: Psychology Department, University of Queensland
-
- I believe there's a very simple algorithm for these puzzles
- that will reach the solution in a reasonable number of moves.
-
- Could anybody tell me what algorithm is? (Most puzzle books
- seem to only use Loyd's 15 puzzle to illustrate parity, saying that
- actually solving the puzzle is trivial...)
-
- I can see plenty of ways of doing it but none of them are
- both simple and efficient for the larger versions of the puzzle.
- (I do have a serious reason for wanting to know...)
-
- It *is* trivial, provided that you are satisfied with a
- less-than-optimal solution (i.e., one that takes more than the least
- possible number of moves). When I was a kid, I could solve the
- 15-puzzle in a few seconds, using the following simple-minded
- algorithm:
-
- for i = 1 to n (where n is the total number of tiles)
- put tile i into its proper place,
- while preserving the locations of tiles 1 through i-1
-
- The only place there's any problem is that you have to temporarily
- disturb the tiles in the second-to-last row in order to get the tiles
- in the last row into their proper order. But there's a simple
- procedure for that, too. Try it a few times and you'll probably
- figure it out.
-
- I haven't taken the time to do a proper complexity analysis, but I
- believe the total number of moves for this algorithm is no worse than
- O(n^4).
- --
- Dana S. Nau
- Computer Science Dept. Internet: nau@cs.umd.edu
- University of Maryland UUCP: uunet!mimsy!nau
- College Park, MD 20742 Telephone: (301) 405-2684
-