Of the 3 before and after, some can be formed in more than one way.
1936 [[1, 4, 4], [4, 2, 2]]
1944 [[6, 1, 8]]
2000 [[5, 2, 0]]
2023 [[7, 1, 7]]
2025 [[1, 4, 5], [9, 1, 5]]
2028 [[3, 2, 6]]
2048 [[2, 3, 2], [8, 1, 6]]
1936 = 1 * 44^2
1936 = 4 * 22^2
1944 = 6 * 18^2
2000 = 5 * 20^2
2023 = 7 * 17^2
2025 = 1 * 45^2
2025 = 9 * 15^2
2028 = 3 * 26^2
2048 = 2 * 32^2
2048 = 8 * 16^2
------------------
my_dict = {}
for a in range(1,10):
for b in range(1,10):
for c in range(10):
x = a * (10*b + c)**2
if x not in my_dict:
my_dict[x] = [[a,b,c]]
else:
my_dict[x].append([a,b,c])
sort_my_dict = sorted(my_dict)
index_2023 = sort_my_dict.index(2023)
solutions = []
for i in range(index_2023 - 3, index_2023 + 4):
print(sort_my_dict[i], my_dict[sort_my_dict[i]])
solutions.append([sort_my_dict[i], my_dict[sort_my_dict[i]]])
print()
for s in solutions:
for triplet in s[1]:
print('{} = {} * {}{}^2'.format(s[0], triplet[0], triplet[1], triplet[2]))
print()
for key in my_dict:
if len(my_dict[key]) >= 3:
print(key, my_dict[key])
|
Posted by Larry
on 2023-12-11 09:02:36 |