Change 234
Change 234 by zz9@zz9-imac-g4 on 2005/11/02 22:07:59
fast: print solve time. 0.004s. ken's main branch: 0.31s. just saying.
Affected files ...| //depot/projects/sudoku/fast/sudoku.c#4 | text |
==== //depot/projects/sudoku/fast/sudoku.c#4 (text) ====
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | #include <stdio.h> |
| 13 | 13 | #include <stdlib.h> |
| 14 | 14 | #include <string.h> |
| 15 | #include <time.h> | |
| 15 | 16 | |
| 16 | 17 | static int grid[9][9]; |
| 17 | 18 | static long nodes = 0; |
| @@ -99,6 +100,7 @@ | ||
| 99 | 100 | { |
| 100 | 101 | FILE *f = stdin; |
| 101 | 102 | int i; |
| 103 | clock_t t0; | |
| 102 | 104 | |
| 103 | 105 | if (argc > 1 && !(f = fopen(argv[1], "r"))) { |
| 104 | 106 | perror(argv[1]); |
| @@ -112,11 +114,13 @@ | ||
| 112 | 114 | if (grid[i / 9][i % 9]) |
| 113 | 115 | place(i / 9, i % 9, grid[i / 9][i % 9]); |
| 114 | 116 | } |
| 117 | t0 = clock(); | |
| 115 | 118 | if (!solve(0)) { |
| 116 | 119 | printf("no solution (are you sure you copied it right?)\n"); |
| 117 | 120 | return 1; |
| 118 | 121 | } |
| 119 | 122 | print_grid(); |
| 120 | fprintf(stderr, "%ld nodes\n", nodes); | |
| 123 | fprintf(stderr, "%ld nodes, %.3fs\n", nodes, | |
| 124 | (double)(clock() - t0) / CLOCKS_PER_SEC); | |
| 121 | 125 | return 0; |
| 122 | 126 | } |