"Solved" Day 4
Literally couldn't be assed to write out the full list of cases in Odin syntax when it's just objectively more cumbersome than Python syntax
This commit is contained in:
BIN
odin/day01.bin
BIN
odin/day01.bin
Binary file not shown.
@@ -7,20 +7,45 @@ check_contains :: proc(pairs: [4]int) -> bool {
|
||||
c := pairs[2]
|
||||
d := pairs[3]
|
||||
|
||||
fmt.printf("%4d,%4d,%4d,%4d\t", a, b, c, d)
|
||||
|
||||
// Invalid input
|
||||
if a > b || c > d {
|
||||
fmt.printf("false\ta > b || c > d\n")
|
||||
return false
|
||||
}
|
||||
|
||||
// A contains B
|
||||
if a <= c && c <= d && d <= b {
|
||||
fmt.printf("true \ta <= c && c <= d && d <= b\n")
|
||||
return true
|
||||
}
|
||||
|
||||
// B contains A
|
||||
if c <= a && a <= b && b <= d {
|
||||
fmt.printf("true \tc <= a && a <= b && b <= d\n")
|
||||
return true
|
||||
}
|
||||
|
||||
// A borders B, B borders A
|
||||
if b == c || d == a {
|
||||
fmt.printf("true \tb == c || d == a \n")
|
||||
return true
|
||||
}
|
||||
|
||||
// A overlaps B
|
||||
if b >= c && b < d {
|
||||
fmt.printf("true \tb >= c && b < d\n")
|
||||
return true
|
||||
}
|
||||
|
||||
// B overlaps A
|
||||
if d >= a && d < b {
|
||||
fmt.printf("true \td >= a && d < b\n")
|
||||
return true
|
||||
}
|
||||
|
||||
fmt.printf("false\n")
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
1035
odin/day04/scratch.py
Normal file
1035
odin/day04/scratch.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user