mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Handle edge case of sgn(x) != sgn(y)
This commit is contained in:
@@ -32,6 +32,10 @@ object solution {
|
||||
}
|
||||
|
||||
def dist(x: Int, y: Int): Int = {
|
||||
return Math.max(x, y);
|
||||
if (x.signum == y.signum) {
|
||||
return Math.max(x.abs, y.abs);
|
||||
} else {
|
||||
return x.abs + y.abs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user