-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
90 lines (62 loc) · 2.2 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.IO;
namespace KakuroSolver
{
public class Program
{
public static void Main(String[] args)
{
var cl = new CommandLine(args);
if ((args.Length == 0) || cl.DoesSwitchExist("help") || cl.DoesSwitchExist("?"))
{
DisplayHelp();
return;
}
var inputFilename = cl[0];
if (!File.Exists(inputFilename))
throw new ArgumentException(String.Format("The input file '{0}' does not exist.", inputFilename));
using (var kakuro = new Kakuro(inputFilename, cl.GetValue("outputfile", ""), cl.GetValue("logfile", ""), cl.DoesSwitchExist("log")))
{
kakuro.Solve();
kakuro.Save();
}
}
private static void DisplayHelp()
{
Console.WriteLine(@"
Kakuro Solver 1.0
by
Chris R. Timmons
http://www.crtimmonsinc.com/
License:
This software and its source code are in the PUBLIC DOMAIN.
See the UNLICENSE.txt file for details.
Source Code:
The C# source code is freely available at https://github.com/ctimmons/cs_kakuro_solver
Usage:
KakuroSolver <input filename> [/output:'output filename']
[/log:'log filename'] [/log]
Optional Parameters:
/outputfile:'output filename'
Filename to write the solved puzzle to. If not provided, defaults
to the input filename with '_SOLUTION' appended.
E.g. 'c:\puzzles\kakuro_5_SOLUTION.txt'
The output file is always created, unless an error occurs.
/logfile:'log filename'
Filename to write log data to. If not provided, defaults
to the input filename with '_LOG' appended.
E.g. 'c:\puzzles\kakuro_5_LOG.txt'
The log file is always created. If the /log switch is not provided,
the log file will only contain a few lines of timing data, and any error
messages.
/log
'/log' turns on logging. Omitting the switch prevents logging.
Log entries are written for each step of the recursive solution's
algorithm.
NB: For hard puzzles, the log file can get very large (> 100 MB), and
have a material impact on the time the program takes to solve the puzzle.
The default is no logging.
");
}
}
}