Skip to content

Instantly share code, notes, and snippets.

@ccw
Created March 26, 2012 04:29
Show Gist options
  • Save ccw/2202929 to your computer and use it in GitHub Desktop.
Save ccw/2202929 to your computer and use it in GitHub Desktop.
[Project Euler in Groovy] - P4
def x = 999
def y = 999
def found = false
def p
while (!found) {
p = String.valueOf(x * y)
def same = true
for (int i = 0; i < p.length() / 2; i++) {
if (p.charAt(i) != p.charAt(p.length() - i - 1)) {
same = false
break
}
}
found = same
if (!found) {
if (y == 836) {
y = 999
x--
} else {
y--
}
}
}
println "$x x $y = $p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment