Non-continuous subsequences: Difference between revisions

m
→‎{{header|REXX}}: added/changed whitespace and comments, elided the STYLE from the PRE html tags.
m (→‎{{header|REXX}}: added/changed whitespace and comments, elided the STYLE from the PRE html tags.)
Line 1,677:
 
=={{header|REXX}}==
<lang rexx>/*REXX program tolists list non-continuous subsequences (NCS), given a seqsequence. */
parse arg list /*theobtain the list from the CLC.L. */
if list='' then list=1 2 3 4 5 /*SpecifiedNot specified? Use default.the default*/
say 'list=' space(list); say /*showdisplay the list to the terminal. */
w=words(list) ; #=0 /*#W: words in list; # of NCS. */
$=left(123456789,w) /*build a string of digitsdecimal digs.*/
tail=right($,max(0,w-2)) /*construct a "fast" tail. */
 
do j=13 to left($,1) || tail /*step through the list. */
if verify(j,$)\==0 then iterate /*Not one of the chosen? */
f=left(j,1) /*use the first1st decimal digit of jJ. */
NCS=0 /*not non-continuous subseqsubsequence.*/
do k=2 to length(j); _=substr(j,k,1) /*pick off a single digit.decimal digit*/
if _ <= f then iterate j /*if next digit ≤, then skip it.*/
if _ \== f+1 then NCS=1 /*it's OK as of now. */
f=_ /*we now gothave a new next decimal dig*/
end /*k*/
 
if \NCS then iterate /*¬not OK? Then skip this numnumber.*/
#=#+1 /*Eureka! We found one.onea digit.*/
x= /*the beginning of the NCS. */
do m=1 for length(j) /*build a thingysequence string to displayshow*/
x=x word(list,substr(j,m,1)) /*pick off a number to showdisplay. */
end /*m*/
 
say 'a non-continuous subsequence: ' x /*show anon─continous non-contsubsequence. subseq. */
end /*j*/
 
if #==0 then #='no' /*make it more gooder EngAnglesh. */
say; say # "non-continuous subsequence"s(#) 'were found.'
exit /*stick a fork in it, we're done.*/
/*────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────S subroutine───────────────────────*/
s: if arg(1)==1 then return ''; return word(arg(2) 's',1) /*plurals.*/</lang>
{{out}}'''output''' &nbsp; when using the input: &nbsp; <tt> 1 2 3 4 </tt>
<pre>
<pre style="overflow:scroll">
list= 1 2 3 4
 
Line 1,722:
5 non-continuous subsequences were found.
</pre>
{{out}}'''output''' &nbsp; when using the following input: &nbsp; <tt> a e I o u </tt>
<pre>
<pre style="overflow:scroll">
list= a e I o u
 
Line 1,745:
16 non-continuous subsequences were found.
</pre>
{{out}}'''output''' &nbsp; when using the following [channel Islands (Great Britain)] as input: &nbsp; <tt> Alderney Guernsey Herm Jersey Sark </tt>
<pre>
<pre style="overflow:scroll">
list= Alderney Guernsey Herm Jersey Sark
 
Line 1,768:
16 non-continuous subsequences were found.
</pre>
{{out}}'''output''' &nbsp; when using the following [six noble gases] as input: &nbsp; <tt> helium neon argon krypton xenon radon </tt>
<pre>
<pre style="overflow:scroll">
list= helium neon argon krypton xenon radon