"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]
|
c := pairs[2]
|
||||||
d := pairs[3]
|
d := pairs[3]
|
||||||
|
|
||||||
|
fmt.printf("%4d,%4d,%4d,%4d\t", a, b, c, d)
|
||||||
|
|
||||||
// Invalid input
|
// Invalid input
|
||||||
if a > b || c > d {
|
if a > b || c > d {
|
||||||
|
fmt.printf("false\ta > b || c > d\n")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// A contains B
|
// A contains B
|
||||||
if a <= c && c <= d && d <= b {
|
if a <= c && c <= d && d <= b {
|
||||||
|
fmt.printf("true \ta <= c && c <= d && d <= b\n")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// B contains A
|
// B contains A
|
||||||
if c <= a && a <= b && b <= d {
|
if c <= a && a <= b && b <= d {
|
||||||
|
fmt.printf("true \tc <= a && a <= b && b <= d\n")
|
||||||
return true
|
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
|
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