ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
Re: [Tutor] 15 puzzle
by Deirdre Saoirse Moen other posts by this author
Apr 28 2001 11:57PM messages near this date
[Tutor] 15 puzzle | Re: [Tutor] 15 puzzle
> Hi! My name is Maritza and I am trying to learn how to program with 
> the python language.  I'm interested in a computer version of the 15 
> puzzle.  I've seen how it works and used it as well, but I am 
> curious about how the program was set up.  Just to make sure that we 
> all know which puzzle I'm refering to, it is the one that you can 
> get at toy stores and is essentially a 4 x 4 matrix with the numbers 
> 1-15 on tiles placed in the matrix.  There is one blank space where 
> tiles adjacent to the blank space may be moved into the blank space. 
> The object of the game is to arrange the numbers 1-15 in order. 
> They are initially scrambled, of course.  If you have this 
> program or can help me put it together, please e-mail me at 
> maritza_rodz.hotmail.com


The best way to set it up would be as a 4  x 4 matrix. That way, it's 
easy to know whether or not any given spot was "next to" the hole -- 
as only something that's up, down, left or right of the hole can move 
there.

Then, you'd swap the space and the number that was there. As Daniel 
said, it's an interesting problem and it could be designed either 
with a command-line interface or a gui one (or done as a command-line 
at first and developed into a GUI program).

-- 
_Deirdre     Stash-o-Matic: http://weirdre.com      http://deirdre.net
"I love deadlines. I like the whooshing sound they make as they fly by."
                                                          - Douglas Adams
Attachments:
unknown1

Thread:
Julieta
Deirdre Saoirse Moen
Daniel Yoo

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved