Re: the rotterdam programming competition
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: the rotterdam programming competition
- From: victor
- Date: Mon, 16 Nov 92 21:33:42 CST
>i have come up with an alternative program which >slightly faster than splitFast splitFast[] can be still a fastest code if we take Block[] off: splitFast[list_,parts_] := Inner[Take[list,{#1,#2}]&, Drop[#1,-1]+1, Rest[#1], List]&[ FoldList[Plus,0,parts] ] My test: parts = Table[Random[Integer,{0,5}],{50000}]; lis = Table[Random[Integer,{1,10}], {parts/.List->Plus}]; Timing[splitFast[lis,parts];] {51.7333 Second, Null} Timing[splitFast[lis,parts];] {51.65 Second, Null} Timing[split[lis,parts];] {52.9167 Second, Null} Timing[split[lis,parts];] {52.9833 Second, Null} >the first point i want to raise is that splitElegant >is really not that elegant I am agree. Victor