How to resolve the algorithm Palindrome detection step by step in the Fantom programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Palindrome detection step by step in the Fantom programming language
Table of Contents
Problem Statement
A palindrome is a phrase which reads the same backward and forward. Write a function or program that checks whether a given sequence of characters (or, if you prefer, bytes) is a palindrome. For extra credit:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Palindrome detection step by step in the Fantom programming language
Source code in the fantom programming language
class Palindrome
{
// Function to test if given string is a palindrome
public static Bool isPalindrome (Str str)
{
str == str.reverse
}
// Give it a test run
public static Void main ()
{
echo (isPalindrome(""))
echo (isPalindrome("a"))
echo (isPalindrome("aa"))
echo (isPalindrome("aba"))
echo (isPalindrome("abb"))
echo (isPalindrome("salàlas"))
echo (isPalindrome("In girum imus nocte et consumimur igni".lower.replace(" ","")))
}
}
You may also check:How to resolve the algorithm Echo server step by step in the Java programming language
You may also check:How to resolve the algorithm Entropy step by step in the BASIC programming language
You may also check:How to resolve the algorithm Search a list step by step in the Ring programming language
You may also check:How to resolve the algorithm Haversine formula step by step in the Symsyn programming language
You may also check:How to resolve the algorithm Draw a rotating cube step by step in the EasyLang programming language