Node *build_tree(Puzzle *instance){ int recheck = 1; while(recheck == 1){ int i; recheck = 0; for(i=0;i<instance->size*instance->size;i++){ if(get_number_of_possibilities(&instance->cells[i]) == 1){ recheck = 1; int value = get_possibility(&instance->cells[i], 0); set_cell_value((&instance->cells[i])->row, (&instance->cells[i])->col, instance, value); } } } printf("Building Tree..\n"); // sort cells in increasing order of possibility list size int *hash = hash_cells(instance); Cell *sorted_list = convert_hash_to_list(hash, instance); print_puzzle(instance); struct timeval start, end; gettimeofday(&start, NULL); Node root = {instance, 0, 0, NULL}; bfs(&root, sorted_list); gettimeofday(&end, NULL); printf("\n\nAlgorithm's computational part duration :%ld\n", \ ((end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec))); }
/* {{{ convert_hash_to_tuple(zval **hash) Convert a PHP hash to a Python tuple */ static PyObject * convert_hash_to_tuple(zval **hash) { return PyList_AsTuple(convert_hash_to_list(hash)); }