Skip to content

Commit 4a4d15b

Browse files
committed
day 03: Transpose the rows
Seems easier to understand than mapping over 0, 1, and 2 and extracting the column.
1 parent 93db477 commit 4a4d15b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

03_triangles.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ def tri?(a, b, c)
66

77
puts input.count { |x| tri?(*x.sort) }
88
puts input.each_slice(3).sum { |rows|
9-
[0, 1, 2].count { |col|
10-
tri?(*rows.map { |r| r[col] }.sort)
11-
}
9+
rows.transpose.count { |x| tri?(*x.sort) }
1210
}

0 commit comments

Comments
 (0)