Created
November 4, 2014 18:12
-
-
Save hayamiz/e2eea81746a2a30a832f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//usr/bin/env go run $0 $@ ; exit | |
package main | |
import ( | |
"fmt" | |
) | |
func isPalindrome(x int) bool { | |
x_str := fmt.Sprintf("%d", x) | |
for i := 0; i < len(x_str) / 2; i++ { | |
if x_str[i] != x_str[len(x_str) - 1 - i] { | |
return false | |
} | |
} | |
return true | |
} | |
func main() { | |
max_val := 0 | |
for x := 100; x < 1000; x++ { | |
for y := 100; y < 1000; y++ { | |
if isPalindrome(x * y) { | |
if x * y > max_val { | |
max_val = x * y | |
} | |
} | |
} | |
} | |
fmt.Println(max_val) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment