File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import urllib.request
2
+ import time
3
+
4
+ #start timer
5
+ start = time.time()
6
+
7
+ #import the problem to access the number easier
8
+ url = "https://projecteuler.net/problem=8"
9
+ data = urllib.request.urlopen(url).read()
10
+ data1 = str(data)
11
+ #assemble the number from the page readout prints in block readout
12
+ locationTracker = data1.find("73167")
13
+ bigNumber = data1[data1.find("73167"):data1.find("73167")+50]
14
+ for j in range(0,19):
15
+ locationTracker = locationTracker + 58
16
+ bigNumber += data1[locationTracker:locationTracker+50]
17
+
18
+ #multiply a string of 13 numbers
19
+ def multiplyNums(string):
20
+ finalProduct = 1
21
+ for index in range(13):
22
+ finalProduct *= int(string[index:index+1])
23
+ return finalProduct
24
+
25
+ #main
26
+ maxProduct = 0
27
+ for index in range(988):
28
+ newProduct = multiplyNums(bigNumber[index:index+13])
29
+ if (newProduct>maxProduct):
30
+ maxProduct = newProduct
31
+
32
+ #end timer
33
+ end = time.time()
34
+
35
+ #prints results
36
+ print("Time: " + str(end - start))
37
+ print("Solution: " + str(maxProduct))
You can’t perform that action at this time.
0 commit comments