My daughter recently noticed that the 10 digits of our old landline phone number are the same digits as those in my wife’s cell phone. The first three digits match exactly because we are in the same area code as before. And the last seven digits of my wife’s cell phone are an exact scrambled version of the last seven digits of the old landline. By “exact scramble,” I mean a string of numbers that is different than the original string of numbers but contains all of the same digits with the exact same number of repetitions (so, for example, if “4” appears exactly three times in the landline number, it also appears exactly three times in my wife’s cell number).
My daughter asked, “What are the odds of that?”
To make this concrete, assume that landlines and cell numbers in my area code are assigned randomly, such that a person is equally likely to get any of the 10,000,000 numbers between and including 000-0000 to 999-9999. Given that assumption, what is the probability that the last seven digits of the cell number are an exact scramble of the last seven digits of our landline?
from itertools import product from collections import defaultdict phone_num_classes = defaultdict(int) for p in product(*([range(10)]*7)): phone_num_classes["".join(sorted(map(str, p)))] += 1 prob = 0 for _, cnt in phone_num_classes.items(): prob += (cnt/10000000)*((cnt-1)/9999999) print(prob)
The probability that the last seven digits of the cell number are an exact scramble of the last seven digits of our landline is $0.017$ percent.