Skip to content

Instantly share code, notes, and snippets.

@hayamiz
Created November 4, 2014 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hayamiz/e2eea81746a2a30a832f to your computer and use it in GitHub Desktop.
Save hayamiz/e2eea81746a2a30a832f to your computer and use it in GitHub Desktop.
//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