aboutsummaryrefslogtreecommitdiff
path: root/day13
diff options
context:
space:
mode:
Diffstat (limited to 'day13')
-rwxr-xr-xday13/part2 (renamed from day13/part2.dnw)23
-rw-r--r--day13/test4
2 files changed, 6 insertions, 21 deletions
diff --git a/day13/part2.dnw b/day13/part2
index af6af5b..71a8ccd 100755
--- a/day13/part2.dnw
+++ b/day13/part2
@@ -30,24 +30,13 @@ end
input = $stdin.readlines.map(&:chomp).map{|l|l.split(': ').map(&:to_i)}
-lcm = input.map(&:last).inject(1, :lcm)
-delay = 0
-
-loop do
- if delay > lcm then
- puts "Went past lcm"
- exit
- end
- firewall = Firewall.new
-
- input.each do |line|
- firewall.add_layer!(line[0], line[1])
- end
-
- break unless firewall.will_capture_at?(delay)
-
- delay += 1
+firewall = Firewall.new
+input.each do |line|
+ firewall.add_layer!(line[0], line[1])
end
+delay = 0
+delay += 1 while firewall.will_capture_at?(delay)
+
puts delay
diff --git a/day13/test b/day13/test
deleted file mode 100644
index 0239024..0000000
--- a/day13/test
+++ /dev/null
@@ -1,4 +0,0 @@
-0: 3
-1: 2
-4: 4
-6: 4