瀏覽代碼

If logic fails, try bruteforce.

Steve Thielemann 6 月之前
父節點
當前提交
7ae1987728
共有 1 個文件被更改,包括 11 次插入5 次删除
  1. 11 5
      src/main.rs

+ 11 - 5
src/main.rs

@@ -25,7 +25,7 @@ fn main() {
         .arg(arg!(-d --debug ... "Debug output").action(ArgAction::SetTrue))
         .get_matches();
 
-    let mut debug : bool = false;
+    let mut debug: bool = false;
     if args.get_flag("debug") {
         debug = true;
     }
@@ -47,15 +47,21 @@ fn main() {
         } else {
             if debug {
                 s.display_possible();
-                }
-        
+            }
+
             while s.solve(debug) {
                 println!("Try it again...");
                 if debug {
-                s.display();
-                s.display_possible();
+                    s.display();
+                    s.display_possible();
                 }
             }
+
+            if !s.puzzle_complete() {
+                println!("Failed to solve by logic alone.  Trying bruteforce.");
+                println!("Bruteforce solutions: {}", s.bruteforce_solver());
+            }
+
             if !debug {
                 s.display();
             }