diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-05-13 23:32:40 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-05-13 23:32:40 -0500 |
commit | 7e7b56db42ceb8d2b8973eae678fa4b58d5d3659 (patch) | |
tree | 7a5cb816809d632e30227c1e39485ed63b500e80 /4.lua | |
download | projecteuler-7e7b56db42ceb8d2b8973eae678fa4b58d5d3659.tar.gz projecteuler-7e7b56db42ceb8d2b8973eae678fa4b58d5d3659.zip |
add old solutions
Diffstat (limited to '4.lua')
-rw-r--r-- | 4.lua | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -0,0 +1,16 @@ +local function is_palindrome(n) + local first_half = string.sub(n, 1, string.len(n) / 2) + local second_half = string.sub(n, -string.len(n) / 2) + return first_half == string.reverse(second_half) +end + +local prods = {} +for i = 100,999 do + for j = 100,i do + table.insert(prods, i * j) + end +end +table.sort(prods, function(a, b) return a > b end) +for _, v in ipairs(prods) do + if is_palindrome(v) then print(v) break end +end |