How to resolve the algorithm Palindrome detection step by step in the langur programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Palindrome detection step by step in the langur 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 langur programming language
Source code in the langur programming language
val .ispal = f len(.s) > 0 and .s == s2s .s, len(.s)..1
val .tests = h{
"": false,
"z": true,
"aha": true,
"αηα": true,
"αννα": true,
"αννασ": false,
"sees": true,
"seas": false,
"deified": true,
"solo": false,
"solos": true,
"amanaplanacanalpanama": true,
"a man a plan a canal panama": false, # true if we remove spaces
"ingirumimusnocteetconsumimurigni": true,
}
for .word in sort(keys .tests) {
val .foundpal = .ispal(.word)
writeln .word, ": ", .foundpal, if(.foundpal == .tests[.word]: ""; " (FAILED TEST)")
}
You may also check:How to resolve the algorithm Loops/Infinite step by step in the EMal programming language
You may also check:How to resolve the algorithm Balanced brackets step by step in the ZX Spectrum Basic programming language
You may also check:How to resolve the algorithm Primality by Wilson's theorem step by step in the Phix programming language
You may also check:How to resolve the algorithm Multiplication tables step by step in the Simula programming language
You may also check:How to resolve the algorithm Gapful numbers step by step in the PL/M programming language