Meine Lösungen zur Coding Challenge vom YouTube Channel Morpheus Tutorials https://www.youtube.com/watch?v=q_4OrvVjWhA&list=PLNmsVeXQZj7rNukSNOVkUnNdhKNZ4sNfA
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

19 lines
527 B

local CC = require('cc')
local function is_palindrome(challenge)
local word = challenge.word:gsub('[^%a]', ''):lower()
local wlen = #word
local half = math.floor(wlen / 2)
local first = word:sub(1, wlen % 2 == 0 and half or half + 1)
local second = word:sub(half + 1, wlen)
return { token = first == string.reverse(second) }
end
local cc = CC.new(15)
for _ = 1, 10 do
local resp = cc:solve(is_palindrome, true)
print(resp)
end
print(string.format('Average time to find the solution: %fs', cc:runtime_avg()))