Skip to content

Commit 8233d01

Browse files
author
Rafal Gajdulewicz
committed
4 solved
1 parent e32032b commit 8233d01

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

4.go

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"strconv"
6+
)
7+
8+
func main() {
9+
max := -1
10+
for i := 999; i >= 100; i-- {
11+
for j := 999; j >= 100; j-- {
12+
mult := i * j
13+
if isPalindrome(mult) {
14+
if mult > max {
15+
max = mult
16+
}
17+
}
18+
}
19+
}
20+
fmt.Println(max)
21+
}
22+
23+
func isPalindrome(num int) bool {
24+
chars := strconv.Itoa(num)
25+
count := len(chars)
26+
for ind := range chars {
27+
if chars[ind] != chars[count-ind-1] {
28+
return false
29+
}
30+
}
31+
return true
32+
}

0 commit comments

Comments
 (0)