adventofcode2022/day04/sol.ivy

21 lines
520 B
Plaintext
Raw Normal View History

2022-12-05 05:40:37 +00:00
sample = 6 4 rho 2 4 6 8 2 3 4 5 5 7 7 9 2 8 3 7 6 6 4 6 2 6 4 8
) get "input.ivy"
op r overlaps s = not (r[2] < s[1]) or (s[2] < r[1])
op r contains s = (r[1] <= s[1]) and (s[2] <= r[2])
op contains x = (x[1 2] contains x[3 4]) or (x[3 4] contains x[1 2])
op overlaps x = (x[1 2] overlaps x[3 4])
2022-12-05 06:10:16 +00:00
#1 3 overlaps 4 5 # -> 0
#1 5 overlaps 2 7 # -> 1
#contains 1 2 3 4 # -> 0
#contains 5 10 7 8 # -> 1
2022-12-05 05:40:37 +00:00
+/ contains transp sample
+/ contains transp input
+/ overlaps transp sample
+/ overlaps transp input