-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsudocore.rb
34 lines (26 loc) · 834 Bytes
/
sudocore.rb
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
## Sudocore - A Sudoku solver written in Ruby.
##
# Prevents ugly error from a user killing the program.
begin
# Parse the command line options and get the filename that holds the puzzle.
require './command_line_parser'
cmd_parser = CommandLineParser.new
options = cmd_parser.parse!
# Create the puzzle with the file.
require './puzzle'
puzzle = Puzzle.new(options.file, options.debug, options.verbose)
# Set up timer with whether user wants to log time info, and to what detail.
require './timer'
timer = Timer.new(options.time, options.verbose)
# Write out the puzzle before it is solved.
puts "Unsolved puzzle:"
puts "#{puzzle.to_s}"
timer.start
puzzle.solve
timer.stop
# Write out the puzzle after it is solved.
puts "Solved puzzle:"
puts "#{puzzle.to_s}"
rescue Interrupt
exit
end