start and goal. You may apply the following action to start any number of times: pick any non-empty piece of consecutive characters and sort its digits in ascending order, leaving the rest of the string as it is.
For example, sorting the piece 826 in 58263 gives 52683.
Return True if start can be turned into goal, and False otherwise.start="5132", goal="1352" → True
Sort the first three digits 513 into 135, which gives 1352.
start="4401", goal="0441" → True
Sort the piece 440 into 044 to get 0441.
start="123", goal="132" → False
Sorting never moves a larger digit in front of a smaller one, so 3 can never get ahead of 2.
start="5132", goal="1352"
True
Run checks the first 3 tests in your browser. Submit checks all 124 tests on the server, hidden ones included.