(E) PalindromeΒΆ

Goal: I will practice implementing recursion.

Instructions: Retrieve the code template: templates/06/palindrome/ -> student/06/palindrome/. For automated testing, the template contains the definition RECURSIVE_FUNC. You need not care about it, and you must not change it.

In the code template, implement function palindrome_recursive that follows a recursive algorithm and returns a truth value telling if the string given as a parameter is a palindrome or not.

Since the aim is to write a recursive function, loops (for or while) are not allowed.

Pay attention to a good programming style.

Example executions:

Enter a word: deleveled
deleveled is a palindrome
Enter a word: delevel
delevel is not a palindrome

Tips for completing the assignment:

  • Start by thinking how to find a trivial case and write it as code.
  • After that try to divide the problem into a smaller instance of the same problem.
  • In this exercise, the string operation substr can be useful, it was introduced in Plussa at 2.6 Strings and characters.

A+ presents the exercise submission form here.