rutty1

5 Reputation

0 Badges

11 years, 160 days

MaplePrimes Activity


These are replies submitted by rutty1

this worked, i feel like there's a less tedious way to get it done though. it seems i combined two procedures, if the list ends in 0 then one of the two will work, same if the list ends in 1.

 

m:=proc(n::list)
local N, S, i, t, T:
N:=nops(n);
S:={}; T:={};
for i from 1 to N do
if n[i]=1 then do
S:=S union {i}; break; od; fi; od;
for i from 1 to N do
if n[i]=0 then do
S:=S union {}; break; od; fi; od; return(S); for t from 1 to N do if n[t]=0 then do T:=T union {}; break; od; fi; od; for t from 1 to N do if n[t]=1 then do T:=T union {t}; break; od; fi; od; return(T);
end proc;

Page 1 of 1