From 19209e13a2b910eb28cbcf4895b1c776670a6beb Mon Sep 17 00:00:00 2001 From: Bonifasius Tarigan <52784596+bonifasiustrg@users.noreply.github.com> Date: Mon, 24 Oct 2022 23:29:43 +0700 Subject: [PATCH 1/2] Palindrome program using recursive function --- python/mysteryRecursive.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 python/mysteryRecursive.py diff --git a/python/mysteryRecursive.py b/python/mysteryRecursive.py new file mode 100644 index 0000000..f2b8c13 --- /dev/null +++ b/python/mysteryRecursive.py @@ -0,0 +1,28 @@ +def mystreryRecursive(str, s, e): + if (s == e): + print("1") + return True + + + + if (s < e + 1): + print("3") + if (str[s] == str[e]): + print("2") + return True + else : + return False + + return mystreryRecursive(str, s+1, e-1) + + return False + +def mystrery(str): + n = len(str) + if (n == 0): + return True + + return mystreryRecursive(str, 0, n-1) + +word = str(input()) +print(mystrery(word)) \ No newline at end of file From b836e0f6c6e00a7fd6c42c92ea4d1324c0d770b4 Mon Sep 17 00:00:00 2001 From: Bonifasius Tarigan <52784596+bonifasiustrg@users.noreply.github.com> Date: Mon, 24 Oct 2022 23:30:47 +0700 Subject: [PATCH 2/2] Rename mysteryRecursive.py to Palindrome_with_recursiveFunc.py --- .../{mysteryRecursive.py => Palindrome_with_recursiveFunc.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename python/{mysteryRecursive.py => Palindrome_with_recursiveFunc.py} (95%) diff --git a/python/mysteryRecursive.py b/python/Palindrome_with_recursiveFunc.py similarity index 95% rename from python/mysteryRecursive.py rename to python/Palindrome_with_recursiveFunc.py index f2b8c13..12839a6 100644 --- a/python/mysteryRecursive.py +++ b/python/Palindrome_with_recursiveFunc.py @@ -25,4 +25,4 @@ def mystrery(str): return mystreryRecursive(str, 0, n-1) word = str(input()) -print(mystrery(word)) \ No newline at end of file +print(mystrery(word))