Day10: tuples are iterable.
This commit is contained in:
parent
8a7eab81e0
commit
f052d8ef78
6
day10.cr
6
day10.cr
@ -12,10 +12,6 @@ struct Tuple(*T)
|
|||||||
def -(other)
|
def -(other)
|
||||||
{self[0]-other[0], self[1] - other[1]}
|
{self[0]-other[0], self[1] - other[1]}
|
||||||
end
|
end
|
||||||
|
|
||||||
def dist
|
|
||||||
self[0] + self[1]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
input = input(2019, 10)
|
input = input(2019, 10)
|
||||||
@ -53,7 +49,7 @@ end
|
|||||||
angle_groups.delete({0,0})
|
angle_groups.delete({0,0})
|
||||||
angle_groups.each do |k, v|
|
angle_groups.each do |k, v|
|
||||||
v.sort! do |a|
|
v.sort! do |a|
|
||||||
(a - p2s).dist
|
(a - p2s).sum
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user