Click here to Skip to main content
15,914,162 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Find an emtpy entry in a 3x3 grid? Pin
BobJanova18-Jul-11 4:49
BobJanova18-Jul-11 4:49 
GeneralRe: Find an emtpy entry in a 3x3 grid? Pin
David198718-Jul-11 4:54
David198718-Jul-11 4:54 
GeneralRe: Find an emtpy entry in a 3x3 grid? Pin
Neo1010118-Jul-11 6:24
Neo1010118-Jul-11 6:24 
GeneralRe: Find an emtpy entry in a 3x3 grid? Pin
David198718-Jul-11 6:31
David198718-Jul-11 6:31 
GeneralRe: Find an emtpy entry in a 3x3 grid? Pin
Neo1010118-Jul-11 6:47
Neo1010118-Jul-11 6:47 
GeneralRe: Find an emtpy entry in a 3x3 grid? Pin
David198718-Jul-11 7:03
David198718-Jul-11 7:03 
GeneralRe: Find an emtpy entry in a 3x3 grid? Pin
Neo1010118-Jul-11 7:04
Neo1010118-Jul-11 7:04 
GeneralRe: Find an emtpy entry in a 3x3 grid? Pin
Wjousts21-Jul-11 9:45
Wjousts21-Jul-11 9:45 
Trying to make sense of what you have in this thread. It looks like you are now trying to change the Grid.Row and Grid.Column of the border control. This is fine. But you also need to move the empty border as well as moving the "sender". Otherwise it's not a swap.
So if you need something like this (I haven't done JS in a while, so consider this semi-pseudocode):

var tempRow = sender['Grid.Row']
var tempCol = sender['Grid.Column']
sender['Grid.Row'] = emptySpot['Grid.Row']
sender['Grid.Column'] = emptySpot['Grid.Column']
emptySpot['Grid.Row'] = tempRow
emptySpot['Grid.Column'] = tempCol

I don't understand why you are trying to remove anything. I think this should work.

A minor performance improvement would be to exit your for loop after you find the empty cell. You know there is only one, so why keep looking after you found it?

A major performance improvement would be to keep track of where the empty cell is, even if you didn't keep track of it when you populated your grid (which would be even better). Once you've found it the first time, you should be able to keep track of it from there on out and never have to search for it again.
QuestionCollision detection? [modified] Pin
Neo1010116-Jul-11 4:29
Neo1010116-Jul-11 4:29 
AnswerRe: Collision detection? [modified] Pin
Wjousts21-Jul-11 9:30
Wjousts21-Jul-11 9:30 
QuestionSorting algorithm problem [modified] Pin
Neo1010115-Jul-11 6:56
Neo1010115-Jul-11 6:56 
AnswerRe: Sorting algorithm problem Pin
Wjousts21-Jul-11 9:02
Wjousts21-Jul-11 9:02 
GeneralData Pin
Burt12313-Jul-11 10:23
Burt12313-Jul-11 10:23 
GeneralRe: Data Pin
Richard MacCutchan13-Jul-11 21:48
mveRichard MacCutchan13-Jul-11 21:48 
GeneralRe: Data Pin
Burt12314-Jul-11 7:37
Burt12314-Jul-11 7:37 
GeneralRe: Data Pin
Richard MacCutchan14-Jul-11 8:11
mveRichard MacCutchan14-Jul-11 8:11 
QuestionModulo statement Pin
Lutosław5-Jul-11 1:44
Lutosław5-Jul-11 1:44 
GeneralRe: Modulo statement Pin
David19875-Jul-11 2:05
David19875-Jul-11 2:05 
GeneralRe: Modulo statement Pin
BobJanova5-Jul-11 2:38
BobJanova5-Jul-11 2:38 
GeneralRe: Modulo statement Pin
David19875-Jul-11 3:13
David19875-Jul-11 3:13 
GeneralRe: Modulo statement Pin
Lutosław5-Jul-11 2:47
Lutosław5-Jul-11 2:47 
GeneralRe: Modulo statement Pin
David19875-Jul-11 3:06
David19875-Jul-11 3:06 
GeneralRe: Modulo statement Pin
Lutosław5-Jul-11 5:19
Lutosław5-Jul-11 5:19 
GeneralRe: Modulo statement Pin
BobJanova5-Jul-11 5:45
BobJanova5-Jul-11 5:45 
GeneralRe: Modulo statement Pin
David19875-Jul-11 6:03
David19875-Jul-11 6:03 

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.