File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ def self.solve_part2(input)
45
45
46
46
groups = groups [ 1 ..-1 ] . map { |group | group . lines [ 1 ..-1 ] . map { |line | line . scan ( /\d +/ ) . map ( &:to_i ) } }
47
47
i = 0
48
- start_time = Time . now
49
48
while true
50
49
num = i
51
50
groups . reverse_each do |group |
@@ -59,7 +58,6 @@ def self.solve_part2(input)
59
58
60
59
seeds . each do |start , stop |
61
60
if num . between? ( start , stop )
62
- puts "Runtime: #{ ( Time . now -start_time ) . round } s"
63
61
return i
64
62
end
65
63
end
@@ -69,4 +67,4 @@ def self.solve_part2(input)
69
67
end
70
68
end
71
69
72
- Day05 . run
70
+ Day05 . run true
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ module Day
11
11
# Instance variables
12
12
attr_accessor :input , :test_input , :test_input1 , :test_input2
13
13
14
- def run
14
+ def run ( track_runtime = false )
15
15
attr_defaults
16
16
puts "--- Running day #{ @num } ---" . yellow
17
17
@@ -22,8 +22,8 @@ def run
22
22
return
23
23
end
24
24
25
- run_part 1
26
- run_part 2
25
+ run_part 1 , track_runtime
26
+ run_part 2 , track_runtime
27
27
end
28
28
29
29
def load_inputs
@@ -63,8 +63,7 @@ def load_inputs
63
63
end
64
64
end
65
65
66
- def run_part ( part )
67
- # TODO: add the option to track the runtime of a solution
66
+ def run_part ( part , track_runtime = false )
68
67
puts "--- Part #{ part } ---" . yellow
69
68
70
69
# Check if the solve_partX method is implemented
@@ -88,8 +87,11 @@ def run_part(part)
88
87
end
89
88
90
89
# Solve this part
90
+ start = Time . now
91
91
result = self . send ( "solve_part#{ part } " , @input )
92
- puts "Result: #{ result } "
92
+ stop = Time . now
93
+
94
+ puts "Result: #{ result } #{ ( track_runtime ? "\t \t (Runtime: #{ stop -start } s)" : "" ) } "
93
95
end
94
96
95
97
def attr_defaults
You can’t perform that action at this time.
0 commit comments