diff options
author | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-12-14 18:33:27 +0000 |
---|---|---|
committer | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-12-14 18:33:27 +0000 |
commit | 697558abc7277dc476e5e63f843e26f4b7f4eb4e (patch) | |
tree | f4df8697e1d359c3f0c15df4c438fe7df6a171f6 /day13 | |
parent | ee1a8bf1499e297ba1a2386ed68cbca2270cebbe (diff) |
Day13 Part2 complete
Diffstat (limited to 'day13')
-rwxr-xr-x | day13/part2 (renamed from day13/part2.dnw) | 23 | ||||
-rw-r--r-- | day13/test | 4 |
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 |