Adopted new convention from template
This commit is contained in:
parent
6b55d7b25e
commit
48bd3200b0
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Created on 03 Jun 2021
|
||||
|
||||
@ -17,9 +17,9 @@ def compute():
|
||||
"""
|
||||
Take the number 192 and multiply it by each of 1, 2, and 3:
|
||||
|
||||
192 × 1 = 192
|
||||
192 × 2 = 384
|
||||
192 × 3 = 576
|
||||
192 x 1 = 192
|
||||
192 x 2 = 384
|
||||
192 x 3 = 576
|
||||
|
||||
By concatenating each product we get the 1 to 9 pandigital,
|
||||
192384576. We will call 192384576 the concatenated product of
|
||||
@ -32,10 +32,9 @@ def compute():
|
||||
What is the largest 1 to 9 pandigital 9-digit number that can
|
||||
be formed as the concatenated product of an integer with
|
||||
(1,2, ... , n) where n > 1?
|
||||
|
||||
"""
|
||||
|
||||
results = []
|
||||
ans = []
|
||||
# Number must 4 digits (exactly) to be pandigital
|
||||
# if n > 1
|
||||
for i in range(1, 10_000):
|
||||
@ -43,14 +42,13 @@ def compute():
|
||||
number = ""
|
||||
while len(number) < 9:
|
||||
number += str(integer * i)
|
||||
if sorted(number) == list('123456789'):
|
||||
results.append(number)
|
||||
if sorted(number) == list("123456789"):
|
||||
ans.append(number)
|
||||
|
||||
integer += 1
|
||||
|
||||
return max(results)
|
||||
return max(ans)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 38: {compute()}")
|
||||
print(f"Result for Problem 38 is {compute()}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user