]> git.itanic.dy.fi Git - sudoku/commitdiff
generator: Print all found sudokus in oneline format
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 20 Jun 2009 18:36:03 +0000 (21:36 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 20 Jun 2009 18:36:03 +0000 (21:36 +0300)
sudoku.cpp
sudoku.h

index bd838dfe85f9d15b576c78f27b2507177aa2b394..167a44cfce739fbfa936a0589142f5a569f4566f 100644 (file)
@@ -122,7 +122,7 @@ int sudoku::str_to_row(const int row, const std::string &str)
 
 void sudoku::print(void)
 {
 
 void sudoku::print(void)
 {
-       int x,y;
+       int x, y;
 
        printf("+-------+------+--------+\n");
        for (y = 0; y < 9; y++) {
 
        printf("+-------+------+--------+\n");
        for (y = 0; y < 9; y++) {
@@ -138,6 +138,19 @@ void sudoku::print(void)
        }
 }
 
        }
 }
 
+void sudoku::print_compact(void)
+{
+       int x, y, i = 0;
+       char str[82];
+       str[81] = 0;
+
+       for (y = 0; y < 9; y++)
+               for (x = 0; x < 9; x++, i++)
+                       str[i] = table[x][y] != EMPTY ? table[x][y] : '.';
+
+       printf("%s\n", str);
+}
+
 void sudoku::clone_to(sudoku &to)
 {
        sudoku clone;
 void sudoku::clone_to(sudoku &to)
 {
        sudoku clone;
@@ -533,8 +546,9 @@ sudoku sudoku::remove_randomly(int min_guesses, int depth)
                                done = 1;
                                #pragma omp flush(done)
                        } else {
                                done = 1;
                                #pragma omp flush(done)
                        } else {
-                               printf("%2d, got only %3d guesses\n", depth,
+                               printf("%2d, got only %3d guesses ", depth,
                                       tmp.guesses);
                                       tmp.guesses);
+                               tmp.print_compact();
                        }
 
                        if (!done) {
                        }
 
                        if (!done) {
index 6ba1136d85dbf1ddfaf03e4dc09b8606bff537fa..774a5f4768c68edf4301de2c581f12d071698013 100644 (file)
--- a/sudoku.h
+++ b/sudoku.h
@@ -12,6 +12,7 @@ public:
        ~sudoku();
 
        void print(void);
        ~sudoku();
 
        void print(void);
+       void print_compact(void);
 
        int set(const int col, const int row, const char num);
        char get(const int col, const int row);
 
        int set(const int col, const int row, const char num);
        char get(const int col, const int row);