# OK to post # PART 2: qSR() PROCEDURE: # ----------------------- qSR:=proc(q,INI,L,n) local r,i,M,ng: r:=nops(L); if nops(INI)<>L[-1][2] then return FAIL; fi; if not (sort(INI)[-1] < q and sort(INI)[1] >= 0) then return FAIL; fi; if not (type(L, list) and {seq(type(L[i], list), i=1..nops(L))} = {true} and {seq(type(L[i][1], posint), i=1..nops(L))} = {true} and {seq(type(L[i][2], posint), i=1..nops(L))} = {true} and sort([seq(L[i][1], i=1..nops(L))])[-1] < q and sort([seq(L[i][1], i=1..nops(L))])[1] >= 0 and sort([seq(L[i][2], i=1..nops(L))]) = [seq(L[i][2], i=1..nops(L))]) then return FAIL; fi; if not type(n,posint) then return FAIL; fi; M:=INI; while(nops(M))