George’s new office has a security
lock in which you have to key in a series of digits, all different, before you
can open the door.
Unfortunately, he
is having trouble committing this security number to memory. So far, he
has memorized a number consisting
a selection of different digits from the
security number.
He made a note of
this memorized number on the memo
sheet on which he was given the security number, but he absent-mindedly
left the paper lying around the house.
When his wife found the paper containing the two numbers, she multiplied them together and found the product
was a seven-digit number in which all
the digits were the same.
What is
George’s security number?
The product can be any of the first 9 multiples of 1111111.
The product can be factored into 2 factors, each with no repeat digits, and such that the digits of the smaller number are all included in the larger one.
The output of the program below is:
239 * 37192 = 8888888
George's security number is 37192.
--------
for n in range(1,10):
alist = factors(n*1111111)
length = int(len(alist)/2)
pairs = []
for k in range(1,length):
a = alist[k]
b = int(n*1111111/alist[k])
sa = str(a)
sb = str(b)
if len(sa) != len(set(sa)):
continue
if len(sb) != len(set(sb)):
continue
contains_all = True
for char in sa:
if char not in sb:
contains_all = False
if contains_all:
print('{} * {} = {}'.format(a, b, n*1111111))
|
Posted by Larry
on 2024-06-12 11:44:50 |