fn solve(mut chips: [u64; 3]) -> u64 { chips.sort_unstable(); let [low, mid, high] = chips; let extra = low & 1; let rings = low - extra; let tower = mid - rings; let last = (high != mid) as u64 & extra; rings * 3 + tower + last } fn main() { assert_eq!(solve([1, 1, 1]), 1); assert_eq!(solve([1, 2, 1]), 2); assert_eq!(solve([4, 1, 1]), 2); dbg!(solve([8, 1, 4])); dbg!(solve([7, 4, 10])); dbg!(solve([12, 12, 12])); dbg!(solve([1, 23, 2])); }
Look at it go!
Explaination in dev.to/qm3ster/comment/1303g
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Rust
Look at it go!
Explaination in dev.to/qm3ster/comment/1303g