-
Notifications
You must be signed in to change notification settings - Fork 0
/
p38.py
36 lines (31 loc) · 770 Bytes
/
p38.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 22 14:16:20 2017
@author: Refaia
"""
import time
def pandigital_1_9(n) :
if len(str(n)) != 9 :
return False
for i in range(1, 10) :
if str(i) not in str(n):
return False
return True
def main() :
delta = time.time()
largestNum = 918273645
num = 9
while num < 10000 :
if str(num)[0] == '9':
concat = ''
n = 1
while len(concat) < 9 :
concat += str(num * n)
n += 1
if pandigital_1_9(concat) :
if int(concat) > largestNum :
largestNum = int(concat)
num += 1
delta = time.time() - delta
return largestNum, delta
print(main())