Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
47
Task/Range-extraction/OxygenBasic/range-extraction.basic
Normal file
47
Task/Range-extraction/OxygenBasic/range-extraction.basic
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
int ints(100)
|
||||
|
||||
ints={
|
||||
0, 1, 2, 4, 6, 7, 8, 11, 12, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 27, 28, 29, 30, 31, 32, 33, 35, 36,
|
||||
37, 38, 39
|
||||
}
|
||||
|
||||
|
||||
' RESULT:
|
||||
' 0-2, 4, 6-8, 11, 12, 14-25, 27-33, 35-39
|
||||
|
||||
|
||||
|
||||
function Ranges(int*i) as string
|
||||
'===============================
|
||||
string pr=""
|
||||
int n=0
|
||||
int e=0
|
||||
int j=0
|
||||
int k=0
|
||||
int f=1
|
||||
do
|
||||
j++
|
||||
n=i(j)
|
||||
e=i(j+1)
|
||||
if e<j
|
||||
exit do
|
||||
endif
|
||||
if e=n+1 and i(j+2)=n+2 then 'LOOKAHEAD
|
||||
if f then k=n : f=0
|
||||
else
|
||||
if f=0 then
|
||||
pr+=k "-" i(j+1) ", " 'RANGE OF VALUES
|
||||
j++
|
||||
f=1
|
||||
else
|
||||
pr+=n ", " 'SINGLE VALUES
|
||||
end if
|
||||
end if
|
||||
loop
|
||||
return left pr, len(pr)-2
|
||||
end function
|
||||
|
||||
|
||||
print Ranges ints
|
||||
Loading…
Add table
Add a link
Reference in a new issue