I'm working a lot with URLs that contain ids and very often, I made a mistake in one digit of the long id and end up with a completely different element. If I don't pay attention, then I end up looking at two elements thinking they are the same and am intrigued until I find out the mistake.
In order to avoid that, I wanted to know if I could make a sequence of ids where making one mistake would not give a valid id. For example, if you have the id 473, then you have to black list all the ids where the first digit is wrong (073, 173, 273, 373, 573, 673, 773, 873, 973) and the second being wrong (403, 413, 423, 433, 443, 453, 463, 483, 493) and the last one (470, 471, 472, 474, 475, 476, 477, 478, 479).
Here is the list of the first pseudo-numbers:
- 011
- 022
- 033
- 044
- 055
- 066
- 077
- 088
- 099
- 101
- 110
- 123
- 132
- 145
- 154
- 167
- 176
- 189
- 198
- 202
- 213
- 220
- 231
- 246
- 257
- 264
- 275
- 303
- 312
- 321
- 330
- 347
- 356
- 365
- 374
- 404
- 415
- 426
- 437
- 440
- 451
- 462
- 473
- 505
- 514
- 527
- 536
- 541
- 550
- 563
- 572
- 606
- 617
- 624
- 635
- 642
- 653
- 660
- 671
- 707
- 716
- 725
- 734
- 743
- 752
- 761
- 770
- 808
- 819
- 880
- 891
- 909
- 918
- 981
- 990
And here is a visual representation of those numbers:
For each digit in the number, we blacklist 9 other numbers. For a 5 digits number (eg 12345), that means blacklisting 45 numbers. For a 10 digits number (eg 1234567890), that means blacklisting 90 numbers. The number of blacklisted numbers only grows at a logarithmic scale.
In order to see how many numbers we lose, I plotted the ratio of pseudo numbers count compared to the real numbers. We can roughly keep one number every fifteen. But the good news is that the ratio doesn't fall off the chart as the numbers grow.
Looking at the numbers, they looked like to go from 10 to 10 but with some huge spikes and sometimes they were closer. So I plotted the difference between two consecutive numbers in a chart and it looks like the difference is centered around 10. But the variance is getting higher and higher as you move further.
I'm not really sure if this sequence can be really useful in practice but that was a fun week-end experiment. I hope it'll give you some, hopefully useful, ideas 🙂