avatar
Bryan Kearney
0

Codes

1

Answers

Code compilers

Top answers

1
given string is palindrome recursion
January-27-2022
-- lua recursive palindrome, by bryankrn https://github.com/llucere/lua-bahamut-challenges/blob/main/src/recursive_palindrome.lua

local function isPalindrome(str)
	if (#str <= 1) then return true end
	local firstChar, lastChar = string.sub(str, 1, 1), string.sub(str, -1, -1)
	if (firstChar == lastChar) then
		return isPalindrome(string.sub(str, 2, -2))
	end
end

print(isPalindrome("tattarrattat"))