Skip to content

Commit afde4e0

Browse files
author
Robb Kidd
committed
2022 Day 14 - as far as I got
1 parent 6c1fb04 commit afde4e0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

2022/ruby/day14.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require_relative "day"
2+
3+
class Day14 < Day
4+
# @example
5+
# day.part1 #=> 24
6+
def part1
7+
@input
8+
.split("\n")
9+
.map do |line|
10+
line
11+
.split(" -> ")
12+
.map { |coords_str| coords_str.split(",").map(&:to_i) }
13+
.each_cons(2)
14+
.map do |wall_ends|
15+
wall_ends.transpose.map { |dim_ends| Range.new(*dim_ends) }
16+
end
17+
end
18+
end
19+
20+
# @example
21+
# day.part2
22+
def part2
23+
end
24+
25+
EXAMPLE_INPUT = <<~INPUT
26+
498,4 -> 498,6 -> 496,6
27+
503,4 -> 502,4 -> 502,9 -> 494,9
28+
INPUT
29+
end

0 commit comments

Comments
 (0)