1033. Moving Stones Until Consecutive Medium

@problem@discussion
#Math#Brainteaser



1/**
2 * [1033] Moving Stones Until Consecutive
3 *
4 * There are three stones in different positions on the X-axis. You are given three integers a, b, and c, the positions of the stones.
5 * In one move, you pick up a stone at an endpoint (i.e., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the stones are currently at positions x, y, and z with x < y < z. You pick up the stone at either position x or position z, and move that stone to an integer position k, with x < k < z and k != y.
6 * The game ends when you cannot make any more moves (i.e., the stones are in three consecutive positions).
7 * Return an integer array answer of length 2 where:
8 * 
9 * 	answer[0] is the minimum number of moves you can play, and
10 * 	answer[1] is the maximum number of moves you can play.
11 * 
12 *  
13 * Example 1:
14 * 
15 * Input: a = 1, b = 2, c = 5
16 * Output: [1,2]
17 * Explanation: Move the stone from 5 to 3, or move the stone from 5 to 4 to 3.
18 * 
19 * Example 2:
20 * 
21 * Input: a = 4, b = 3, c = 2
22 * Output: [0,0]
23 * Explanation: We cannot make any moves.
24 * 
25 * Example 3:
26 * 
27 * Input: a = 3, b = 5, c = 1
28 * Output: [1,2]
29 * Explanation: Move the stone from 1 to 4; or move the stone from 1 to 2 to 4.
30 * 
31 *  
32 * Constraints:
33 * 
34 * 	1 <= a, b, c <= 100
35 * 	a, b, and c have different values.
36 * 
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/moving-stones-until-consecutive/
41// discuss: https://leetcode.com/problems/moving-stones-until-consecutive/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46    pub fn num_moves_stones(a: i32, b: i32, c: i32) -> Vec<i32> {
47        vec![]
48    }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn test_1033() {
59    }
60}
61


Back
© 2025 bowen.ge All Rights Reserved.