Skip to content

Commit 40abe78

Browse files
authored
Problem 4
Find the largest palindrome made from the product of two 3-digit numbers.
1 parent 1f4cda8 commit 40abe78

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Problem 4

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import time
2+
3+
#start time
4+
start = time.time()
5+
6+
#Brute force multiply then check for symmetry
7+
j = 999
8+
currentMax = 0
9+
while j > 0:
10+
x = 999
11+
while x > 0:
12+
l = j*x
13+
z = str(l)
14+
if len(z) == 6:
15+
if z[0] == z[5]:
16+
if z[1] == z[4]:
17+
if z[2] == z[3]:
18+
if l > currentMax:
19+
currentMax = l
20+
x = x - 1
21+
j = j - 1
22+
23+
#end timer
24+
end = time.time()
25+
26+
#prints results
27+
print(end-start)
28+
print(currentMax)

0 commit comments

Comments
 (0)