Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Range-expansion/DWScript/range-expansion.dw
Normal file
15
Task/Range-expansion/DWScript/range-expansion.dw
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function ExpandRanges(ranges : String) : array of Integer;
|
||||
begin
|
||||
for var range in ranges.Split(',') do begin
|
||||
var separator = range.IndexOf('-', 2);
|
||||
if separator > 0 then begin
|
||||
for var i := range.Left(separator-1).ToInteger to range.Copy(separator+1).ToInteger do
|
||||
Result.Add(i);
|
||||
end else begin
|
||||
Result.Add(range.ToInteger)
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
var expanded := ExpandRanges('-6,-3--1,3-5,7-11,14,15,17-20');
|
||||
PrintLn(JSON.Stringify(expanded));
|
||||
Loading…
Add table
Add a link
Reference in a new issue