The TransCompilator

Solved LeetCode program · 796 of 1,000

#1033 · Moving Stones Until Consecutive

Medium Math chunk-16.md

Original English source

The stones is a list of 1, 2, and 5. Sort stones. The smallest is item 0 of stones. The middle is item 1 of stones. The largest is item 2 of stones. The firstgap is middle minus smallest. The secondgap is largest minus middle. The fewest is 2. If firstgap is 1 and secondgap is 1, set fewest to 0. If firstgap is 2 or secondgap is 2, set fewest to 1. If firstgap is 1 and secondgap is more than 1, set fewest to 1. The most is largest minus smallest minus 2. Show fewest. Show most.

Open in Playground Browse all 1,000 problems

Expected stdout

1
2