Skip to content

Commit 4b17731

Browse files
committed
Clean up 2023 day 13, second part
1 parent 7123e68 commit 4b17731

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

2023/day13/day13b

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ def is_symmetry_line?(lines, (a, b))
1111
end
1212

1313
def find_symmetry(lines)
14-
puts "find_symmetry for:"
15-
puts lines
1614
idx_pairs = []
1715
lines.each_with_index.each_cons(2) do |((line_a, idx_a), (line_b, idx_b))|
1816
idx_pairs << [idx_a, idx_b] if line_a == line_b
@@ -36,33 +34,23 @@ def summarize(pattern)
3634
find_symmetry(lines.map(&:chars).transpose.map(&:join))[0]
3735
end
3836

39-
puts "original: #{original}"
4037
counts = Set[original]
4138

4239
(0...lines.length).each do |y|
4340
(0...lines[0].length).each do |x|
44-
puts "Swapping at #{y}/#{x}, counts is #{counts}"
4541
new_lines = lines.map(&:clone)
46-
new_lines[y][x] = new_lines[y][x] == "#" ? "." : "#"
42+
new_lines[y][x] = (new_lines[y][x] == "#") ? "." : "#"
4743

4844
count_new = find_symmetry(new_lines)
49-
if count_new
50-
puts "found #{count_new}"
51-
count_new.each { |c| counts.add(100 * c) }
52-
end
45+
count_new&.each { |c| counts.add(100 * c) }
5346

5447
count_new = find_symmetry(new_lines.map(&:chars).transpose.map(&:join))
55-
if count_new
56-
puts "found #{count_new}"
57-
count_new.each { |c| counts.add(c) }
58-
end
48+
count_new&.each { |c| counts.add(c) }
5949
end
6050

6151
break if counts.size == 2
6252
end
6353

64-
puts "original: #{original}"
65-
p counts
6654
counts.to_a.find { |c| c != original }
6755
end
6856

0 commit comments

Comments
 (0)