Ring
Ring Distance
On a ring of length
nwhere the ids are0..n, what is the distance between two positionuandv.
There are two 2 distances.
let (src, dst) = (u.min(v), u.max(v));
let d1 = dst - src;
let d2 = n - d1;
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
On a ring of length
nwhere the ids are0..n, what is the distance between two positionuandv.
There are two 2 distances.
let (src, dst) = (u.min(v), u.max(v));
let d1 = dst - src;
let d2 = n - d1;