How to resolve the algorithm Range expansion step by step in the TUSCRIPT programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Range expansion step by step in the TUSCRIPT programming language
Table of Contents
Problem Statement
A format for expressing an ordered list of integers is to use a comma separated list of either Example The list of integers: Is accurately expressed by the range expression: (And vice-versa).
Expand the range description: Note that the second element above, is the range from minus 3 to minus 1.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Range expansion step by step in the TUSCRIPT programming language
Source code in the tuscript programming language
$$ MODE TUSCRIPT
rangednrs="-6,-3--1,3-5,7-11,14,15,17-20"
expandnrs=SPLIT (rangednrs,":,:")
LOOP/CLEAR r=expandnrs
test=STRINGS (r,":><-><<>>/:")
sz_test=SIZE (test)
IF (sz_test==1) THEN
expandnrs=APPEND (expandnrs,r)
ELSE
r=SPLIT (r,"::<|->/::-:",beg,end)
expandnrs=APPEND (expandnrs,beg)
LOOP/CLEAR next=beg,end
next=next+1
expandnrs=APPEND (expandnrs,next)
IF (next==end) EXIT
ENDLOOP
ENDIF
ENDLOOP
expandnrs= JOIN (expandnrs,",")
PRINT expandnrs
You may also check:How to resolve the algorithm Anagrams step by step in the J programming language
You may also check:How to resolve the algorithm Repeat step by step in the Pascal programming language
You may also check:How to resolve the algorithm Cumulative standard deviation step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Command-line arguments step by step in the Sidef programming language
You may also check:How to resolve the algorithm Angles (geometric), normalization and conversion step by step in the XPL0 programming language