Distinct palindromes within decimal numbers: Difference between revisions

m
→‎{{header|REXX}}: added the extra strings used by another programming language entry.
m (→‎{{header|REXX}}: allowed the use of numbers/words of any length, not just the width of last entry.)
m (→‎{{header|REXX}}: added the extra strings used by another programming language entry.)
Line 333:
 
=={{header|REXX}}==
This REXX version can handle strings or numbers,   a hexadecimal string is included in the examples.
<lang>/*REXX program finds distinct palindromes contained in substrings (of decimal numbers). */
parse arg LO HI mL $$ /*obtain optional arguments from the CL*/
Line 341:
if $$='' | $$="," then $$= 9 169 12769 1238769 12346098769 1234572098769 123456832098769,
12345679432098769 1234567905432098769 123456790165432098769 ,
83071934127905179083 'deadbeef' /* (hexadecimal) */ 1320267947849490361205695,
1320267947849490361205695'Do these strings contain a minimum two character /* special numbers.*/palindrome?'
w= length(HI) /*max width of LO ──► HI for alignment.*/
 
Line 349:
end /*j*/
 
w#= length( word($$, words($$); ) ) if #==0 then exit 0 /*findNo thespecial lengthwords/numbers? of theThen last special #exit.*/
 
if words($$)==0 then exit 0 /*No special words/numbers? Then exit.*/
do m=1 for #; w= max(w, length(word($$, m))) /*find max width string in $$*/
end /*m*/
say
do j=1 for words($$)#; z= word($$, j) /*obtain a string in the $$ list. */
#= Dpal(z, mL); w= max(w, length(z) ) /*get # distinct palindromes, minLen=mL*/
_= left(':', #>0); @has= ' has '; @of='of length'
say right(z, w) @has # " palindrome"s(#,,' ') @of mL "or more"_ space($)
Line 410 ⟶ 412:
123456790165432098769 has 0 palindromes of length 2 or more
83071934127905179083 has 0 palindromes of length 2 or more
deadbeef has 1 palindrome of length 2 or more: ee
1320267947849490361205695 has 3 palindromes of length 2 or more: 202 494 949
Do has 0 palindromes of length 2 or more
deadbeef these has 1 palindrome of length 2 or more: eeese
strings has 0 palindromes of length 2 or more
contain has 0 palindromes of length 2 or more
a has 0 palindromes of length 2 or more
minimum has 3 palindromes of length 2 or more: minim ini mum
two has 0 palindromes of length 2 or more
character has 1 palindrome of length 2 or more: ara
palindrome? has 0 palindromes of length 2 or more
</pre>