/*
* @lc app=leetcode.cn id=1033 lang=typescript
*
* [1033] 移动石子直到连续
*/
// @lc code=start
// @lc code=end
function numMovesStones(a: number, b: number, c: number): number[] {
;[a, b, c] = [a, b, c].sort((a, b) => a - b)
let x = Math.min(2, b - a - 1, c - b - 1)
if (a + 1 === b && b + 1 === c) x = 0
else if (a + 1 === b || b + 1 === c) x = 1
return [x, c - a - 2]
}
test.each([
{ input: { a: 1, b: 2, c: 5 }, output: [1, 2] },
{ input: { a: 4, b: 3, c: 2 }, output: [0, 0] },
{ input: { a: 3, b: 5, c: 1 }, output: [1, 2] },
])('input: a = $input.a, b = $input.b, c = $input.c', ({ input: { a, b, c }, output }) => {
expect(numMovesStones(a, b, c)).toEqual(output)
})