Hi there!
I was working on a Sudoku Generator. While trying different approaches i tried to create a Tree in which every node contains a partial generation, and if it can't go on that node is bounded. Eventually it should find a solution.
The algorithm is not the problem, just take a look at this!
The first NSLog prints
the second one (in visitNode) prints:
or other random numbers..
I think the problem happens when i pass the variable, but i couldn't figure it out. Could you please help me?
Thanks in advance
I was working on a Sudoku Generator. While trying different approaches i tried to create a Tree in which every node contains a partial generation, and if it can't go on that node is bounded. Eventually it should find a solution.
The algorithm is not the problem, just take a look at this!
Code:
-(void) solve{
ConstraintGraph *g = [[ConstraintGraph alloc] initAsSudoku];
SolutionTree *tree = [[SolutionTree alloc] init];
tree.root->info = (Node*)(g.nodeList->Head->info);
tree.root->info->n = 3;
NSLog(@"the value is %d", tree.root->info->n);
* * * *//this prints 'the value is 3'
[self visitNode:tree.root];
}
-(void) visitNode:(solutionTreeNode*)N{
* * * *//this prints 'the value is 1296' (or another number)
NSLog(@"he value is %d", N->info->n);
}
The first NSLog prints
Code:
the value is 3
the second one (in visitNode) prints:
Code:
the value is 1456
I think the problem happens when i pass the variable, but i couldn't figure it out. Could you please help me?
Thanks in advance