Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

Pages: **1**

**Dries****Guest**

Let's play a little game. (I'm sure someone has come up with this before.)

Suppose you start with any number.

Let's say: 1253

Now you may transform this number into a different number by switching any two digits (let's say a and b) of this number.

However, you may only do so if the difference between those digits (a - b or b - a) is the same as their distance between them in this number.

We can start out by switching 1 and 2. No other move is possible.

Their difference: 2 - 1 = 1.

Their distance from each other in this number: They're right next to each other. So they're 1 apart from each other.

Difference and distance is the same, so we may switch them.

Now we get: 2153

And now the same thing applies. Which number(s) can we reach from this number? Seems like we can switch 1 and 3 here.

You may actually succeed in reversing all the digits. 1253 would be converted into 3521.

It would however take no less than 14 steps to do so. In fact, 3521 is the furthest away from 1253.

So the shortest path between them, takes 14 steps. And there is no other number that can be reached and that needs more steps to be reached, when using the shortest path to reach it.

Now here is a related problem which programmers may like, for any number n, what's the number that's furthest away from n?

And how many steps would you need to take to be able to reach it?

We have now solved it for 1253.

I've made a little program but I'm a lousy programmer.

The longest path I have found so far, is 72 steps long.

It's for the number 204075, among others.

(I have allowed it to let the 0 be the first digit when transforming it into another number. It was the simplest thing to do. But I've only started out with numbers that don't begin with a 0. You may choose to not allow a 0 in front, of course. Or to remove that 0 when it does come on front of the number.)

I wonder if anyone is interested in breaking the record.

**Denominator****Member**- Registered: 2009-11-23
- Posts: 217

This is a cool and interesting problem!

I wrote some code and let it run for a few hours and it generated this sequence:

So the longest path I have found is 74 steps, and the smallest number I have found that achieved this is 103682. (If my code is right.)

Maybe we could add this sequence onto OEIS!

Also, I chose to not allow leading 0s.

*Last edited by Denominator (2021-01-03 12:10:47)*

Offline

**Dries****Member**- Registered: 2021-01-05
- Posts: 1

Cool. Glad you think so.

I had similar results. The most I've found was 75 steps for 830612 towards 13682.

This time, I removed 0 when it came in front.

This was simpler to implement. I see that you have stopped when you'd loose a digit. Seems cool too.

I have the same result for 103682. It takes 74 steps.

Not sure you would post it to OEIS? All fine by me.

Offline

Pages: **1**