The product of 722*227 (163,894) contains neither 2 nor 7.
List all the couples (b,c; b>c) such that the product bcc*ccb contains neither b nor c.
Bonus: From the above list select couples, if any, using none of the corresponding digits in the partial products as well.
Also solved, same solution as Steven Lord.
b c bcc ccb b*c
3 2 322 223 71806
7 2 722 227 163894
7 4 744 447 332568
8 5 855 558 477090
7 6 766 667 510922
All the couples: [[3, 2], [7, 2], [7, 4], [8, 5], [7, 6]]
Bonus: just the couples lacking the corresponding digits in the partial products as well:
[3, 2]
[7, 2]
the code:
print('b c bcc ccb b*c')
solutions = []
for c in range(0,10):
for b in range(c+1,10):
prod =(100*b + 11*c) * (110*c + b)
s = str(prod)
if str(b) in s:
continue
if str(c) in s:
continue
print(b,c,(100*b + 11*c),(110*c + b), (100*b + 11*c) * (110*c + b))
solutions.append([b,c])
print('All the couples: ', solutions, '\n')
print('Bonus: just the couples lacking the corresponding digits in the partial products as well: ')
for aList in solutions:
b = aList[0]
c = aList[1]
x = (100*b + 11*c)
y = (110*c + b)
partialProducts = str(x*b)+str(x*c)+str(y*b)+str(y*c)
if str(b) in partialProducts:
continue
if str(c) in partialProducts:
continue
print(aList)
|
Posted by Larry
on 2020-11-28 08:39:07 |