Click here to Skip to main content
15,923,909 members
Home / Discussions / Algorithms
   

Algorithms

 
Question15 puzzle solution in C or C++ Pin
123lucy457-Apr-10 5:25
123lucy457-Apr-10 5:25 
AnswerRe: 15 puzzle solution in C or C++ Pin
Luc Pattyn7-Apr-10 5:56
sitebuilderLuc Pattyn7-Apr-10 5:56 
GeneralRe: 15 puzzle solution in C or C++ Pin
Paul Conrad7-Apr-10 6:35
professionalPaul Conrad7-Apr-10 6:35 
AnswerRe: 15 puzzle solution in C or C++ Pin
Dave Kreskowiak7-Apr-10 7:03
mveDave Kreskowiak7-Apr-10 7:03 
GeneralRe: 15 puzzle algorithm in C or C++ Pin
123lucy457-Apr-10 16:11
123lucy457-Apr-10 16:11 
GeneralRe: 15 puzzle algorithm in C or C++ Pin
Luc Pattyn7-Apr-10 17:07
sitebuilderLuc Pattyn7-Apr-10 17:07 
GeneralRe: 15 puzzle algorithm in C or C++ Pin
Dave Kreskowiak7-Apr-10 17:42
mveDave Kreskowiak7-Apr-10 17:42 
GeneralRe: 15 puzzle algorithm in C or C++ Pin
Alan Balkany9-Apr-10 4:28
Alan Balkany9-Apr-10 4:28 
I'll give you a starting point. This puzzle can be solved efficiently with three algorithms:

1. The simple case: For numbers not in the rightmost column or the last two rows, move tiles to create a blank space between the next tile to place, and the correct location for this tile. Then move the tile into the blank space, bringing you one step closer to correct placement for this tile. Repeat until the tile is in the correct location.

2. For a position in the rightmost column (but not the last two rows), the problem is getting the wrong tile out and the right tile in. Get the right tile under the correct location (in the rightmost column). Then move another tile in the same row as the correct location down one (temporarily moving it out of its correct location), slide the rest of the row to the left, move the right tile up (to its correct position), get a blank spot under the wrong tile, move the wrong tile down, move the rest of the row right, then move the tile you moved out of its correct position back, thus completing the row.

3. For the last two rows, move them in a circular pattern until you get the opportunity to swap two tiles that are in the wrong order. Repeat until the last two rows are correct.
QuestionA simple algorithm request Pin
Michael J. Eber24-Mar-10 13:19
Michael J. Eber24-Mar-10 13:19 
AnswerRe: A simple algorithm request Pin
Amar Chaudhary24-Mar-10 15:25
Amar Chaudhary24-Mar-10 15:25 
AnswerRe: A simple algorithm request Pin
Dr.Walt Fair, PE24-Mar-10 15:29
professionalDr.Walt Fair, PE24-Mar-10 15:29 
AnswerRe: A simple algorithm request Pin
Luc Pattyn24-Mar-10 15:54
sitebuilderLuc Pattyn24-Mar-10 15:54 
QuestionFilling a cylinder or a tube Pin
Valeriant20-Mar-10 17:46
Valeriant20-Mar-10 17:46 
AnswerRe: Filling a cylinder or a tube Pin
Moreno Airoldi21-Mar-10 0:08
Moreno Airoldi21-Mar-10 0:08 
GeneralRe: Filling a cylinder or a tube Pin
Valeriant21-Mar-10 4:46
Valeriant21-Mar-10 4:46 
GeneralRe: Filling a cylinder or a tube Pin
Moreno Airoldi21-Mar-10 8:33
Moreno Airoldi21-Mar-10 8:33 
GeneralRe: Filling a cylinder or a tube Pin
Valeriant21-Mar-10 16:36
Valeriant21-Mar-10 16:36 
GeneralRe: Filling a cylinder or a tube Pin
Moreno Airoldi25-Mar-10 2:06
Moreno Airoldi25-Mar-10 2:06 
GeneralRe: Filling a cylinder or a tube Pin
Valeriant25-Mar-10 19:34
Valeriant25-Mar-10 19:34 
GeneralRe: Filling a cylinder or a tube Pin
Moreno Airoldi25-Mar-10 22:24
Moreno Airoldi25-Mar-10 22:24 
GeneralRe: Filling a cylinder or a tube Pin
Moreno Airoldi2-Apr-10 23:02
Moreno Airoldi2-Apr-10 23:02 
GeneralRe: Filling a cylinder or a tube Pin
Valeriant6-Apr-10 2:21
Valeriant6-Apr-10 2:21 
GeneralRe: Filling a cylinder or a tube Pin
Moreno Airoldi6-Apr-10 4:11
Moreno Airoldi6-Apr-10 4:11 
GeneralRe: Filling a cylinder or a tube Pin
Andy_L_J25-Mar-10 19:50
Andy_L_J25-Mar-10 19:50 
GeneralRe: Filling a cylinder or a tube Pin
Moreno Airoldi25-Mar-10 22:27
Moreno Airoldi25-Mar-10 22:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.