Non-continuous subsequences: Difference between revisions
Content added Content deleted
(Added Wren) |
(→{{header|REXX}}: added/changed whitespace and comments, used templates for the output sections.) |
||
Line 2,160:
=={{header|REXX}}==
This REXX version also works with non-numeric (alphabetic) items (as well as numbers).
<lang rexx>/*REXX program lists all the non─continuous subsequences (NCS), given a sequence.
parse arg list /*obtain
if list='' | list==
say 'list=' space(list);
w= words(list)
tail= right(
#= 0
do j=13 to left(
if verify(j,
f= left(j, 1)
NCS= 0
do k=2
$=
do m=1 for length(j) /*build a sequence string to display. */
$= $ word(list, substr(j, m, 1) ) /*obtain a number (or item) to display.*/
▲ if \NCS then iterate /*not OK? Then skip this number (item)*/
say
if #==0 then #= 'no'
▲ end /*m*/
▲ say 'a non─continuous subsequence: ' @ /*show the non─continuous subsequence. */
▲ end /*j*/
▲if #==0 then #='no' /*make it look more gooder Angleshy. */
▲say # "non─continuous subsequence"s(#) 'were found.'
▲exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
s: if arg(1)==1 then return '';
<pre>
list= 1 2 3 4
Line 2,204 ⟶ 2,205:
5 non-continuous subsequences were found.
</pre>
<pre>
list= a e I o u
Line 2,227 ⟶ 2,228:
16 non-continuous subsequences were found.
</pre>
<pre>
list= Alderney Guernsey Herm Jersey Sark
Line 2,250 ⟶ 2,251:
16 non-continuous subsequences were found.
</pre>
<pre>
list= helium neon argon krypton xenon radon
|