How to resolve the algorithm Palindrome detection step by step in the Applesoft BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Palindrome detection step by step in the Applesoft BASIC 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 Applesoft BASIC programming language

Source code in the applesoft programming language

100 DATA"MY DOG HAS FLEAS"
110 DATA"MADAM, I'M ADAM."
120 DATA"1 ON 1"
130 DATA"IN GIRUM IMUS NOCTE ET CONSUMIMUR IGNI"
140 DATA"A man, a plan, a canal: Panama!"
150 DATA"KAYAK"
160 DATA"REDDER"
170 DATA"H"
180 DATA""

200 FOR L1 = 1 TO 9
210    READ W$ : GOSUB 300" IS PALINDROME?
220    PRINT CHR$(34); W$; CHR$(34); " IS ";
230    IF NOT PALINDROME THEN PRINT "NOT ";
240    PRINT "A PALINDROME"
250 NEXT
260 END

300 REMIS PALINDROME?
310 PA = 1
320 L = LEN(W$)
330 IF L = 0 THEN RETURN
340 FOR L0 = 1 TO L / 2 + .5
350     PA = MID$(W$, L0, 1) = MID$(W$, L - L0 + 1, 1)
360     IF PALINDROME THEN NEXT L0
370 RETURN

  

You may also check:How to resolve the algorithm Constrained genericity step by step in the OCaml programming language
You may also check:How to resolve the algorithm Maximum triangle path sum step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Best shuffle step by step in the Nim programming language
You may also check:How to resolve the algorithm Terminal control/Dimensions step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Loops/Nested step by step in the ZX Spectrum Basic programming language