Application entry point. @param args Command line arguments: solution limit
(String[] args)
| 74 | */ |
| 75 | |
| 76 | public static void main(String[] args) |
| 77 | { int N = 2098; |
| 78 | |
| 79 | // ... parse command line arguments |
| 80 | |
| 81 | if (args.length > 0) |
| 82 | if (args[0].matches("\\d+")) |
| 83 | N = Integer.parseInt(args[0]); |
| 84 | |
| 85 | // ... solve puzzle |
| 86 | |
| 87 | meteor puzzle = new meteor (); |
| 88 | Date start; |
| 89 | Date end; |
| 90 | long time; |
| 91 | SortedSet<String> solutions; |
| 92 | |
| 93 | start = new Date(); |
| 94 | solutions = puzzle.solve(); |
| 95 | end = new Date(); |
| 96 | time = end.getTime() - start.getTime(); |
| 97 | |
| 98 | // ... print result |
| 99 | |
| 100 | if (solutions.size() > N) |
| 101 | System.out.println("ERROR"); |
| 102 | else if (solutions.size() < N) |
| 103 | System.out.println("TIMEOUT"); |
| 104 | else |
| 105 | { if (DEBUG) |
| 106 | { System.out.println("START : " + start); |
| 107 | System.out.println("END : " + end); |
| 108 | System.out.println("TIME : " + time); |
| 109 | System.out.println("SOLUTIONS: " + solutions.size ()); |
| 110 | System.out.println("FIRST : " + solutions.first()); |
| 111 | System.out.println("LAST : " + solutions.last ()); |
| 112 | System.out.println(); |
| 113 | } |
| 114 | |
| 115 | System.out.print(solutions.size () + " solutions found\n\n"); |
| 116 | print(solutions.first()); |
| 117 | System.out.print("\n"); |
| 118 | print(solutions.last ()); |
| 119 | System.out.print("\n"); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /** Prints out the puzzle. |
| 124 | * |