Ring
Ring Distance
On a ring of length
n
where the ids are0..n
, what is the distance between two positionu
andv
.
There will two 2 distance.
let (src, dst) = (u.min(v), u.max(v));
let d1 = dst - src;
let d2 = n - d1;
On a ring of length
n
where the ids are0..n
, what is the distance between two positionu
andv
.
There will two 2 distance.
let (src, dst) = (u.min(v), u.max(v));
let d1 = dst - src;
let d2 = n - d1;