fork download
  1. def find_two_digit_numbers():
  2. target_product = 2 * (2024 ** 3)
  3. for a in range(1, 10): # a cannot be 0
  4. for b in range(10):
  5. for c in range(10):
  6. for d in range(10):
  7. for e in range(10):
  8. for f in range(10):
  9. for g in range(10):
  10. for h in range(10):
  11. ab = 10 * a + b
  12. bc = 10 * b + c
  13. cd = 10 * c + d
  14. de = 10 * d + e
  15. ef = 10 * e + f
  16. fg = 10 * f + g
  17. gh = 10 * g + h
  18. product = ab * bc * cd * de * ef * fg * gh
  19. if product == target_product:
  20. return [ab, bc, cd, de, ef, fg, gh]
  21. return None
  22.  
  23. result = find_two_digit_numbers()
  24. if result:
  25. print("The seven two-digit numbers are:", result)
  26. else:
  27. print("No solution found.")
  28.  
Success #stdin #stdout 0.03s 25736KB
stdin
Standard input is empty
stdout
def find_two_digit_numbers():
    target_product = 2 * (2024 ** 3)
    for a in range(1, 10):  # a cannot be 0
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    for e in range(10):
                        for f in range(10):
                            for g in range(10):
                                for h in range(10):
                                    ab = 10 * a + b
                                    bc = 10 * b + c
                                    cd = 10 * c + d
                                    de = 10 * d + e
                                    ef = 10 * e + f
                                    fg = 10 * f + g
                                    gh = 10 * g + h
                                    product = ab * bc * cd * de * ef * fg * gh
                                    if product == target_product:
                                        return [ab, bc, cd, de, ef, fg, gh]
    return None

result = find_two_digit_numbers()
if result:
    print("The seven two-digit numbers are:", result)
else:
    print("No solution found.")