tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,6 @@
|
|||
fn isPalindrome s =
|
||||
(
|
||||
local reversed = ""
|
||||
for i in s.count to 1 by -1 do reversed += s[i]
|
||||
return reversed == s
|
||||
)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
fn isPalindrome_r s =
|
||||
(
|
||||
if s.count <= 1 then
|
||||
(
|
||||
true
|
||||
)
|
||||
else
|
||||
(
|
||||
if s[1] != s[s.count] then
|
||||
(
|
||||
return false
|
||||
)
|
||||
isPalindrome_r (substring s 2 (s.count-2))
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
local p = "ingirumimusnocteetconsumimurigni"
|
||||
format ("'%' is a palindrome? %\n") p (isPalindrome p)
|
||||
format ("'%' is a palindrome? %\n") p (isPalindrome_r p)
|
||||
Loading…
Add table
Add a link
Reference in a new issue