RE: Re: Super-Increasing List
- To: mathgroup at smc.vnet.net
- Subject: [mg40488] RE: [mg40459] Re: [mg40438] Super-Increasing List
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Tue, 8 Apr 2003 03:02:35 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
This is a bit obfuscated,... Catch[Fold[If[#1 < #2, #1 + #2, Throw[False]] &, First[t], Rest[t]]; True] ...will do. Bob Hanlon's solution assumes all list elements to be positive; however, this might be accounted for: And @@ Thread[Drop[FoldList[Plus, First[t], Rest[t]], -1] < Rest[t]] Bill Rowe made the same assumption and additionally checked for the sequence to be increasing (which is not neccessary), furthermore OrderedQ is not quite appropiate (apart from being less efficient), as In[39]:= OrderedQ[{1, 1}] Out[39]= True -- Hartmut Wolf >-----Original Message----- >From: Dr Bob [mailto:majort at cox-internet.com] To: mathgroup at smc.vnet.net >Sent: Sunday, April 06, 2003 10:35 AM >To: mathgroup at smc.vnet.net >Subject: [mg40488] [mg40459] Re: [mg40438] Super-Increasing List > > >superIncreasing[t_List] := > Catch[ > Fold[If[And @@ Thread[#1 < #2], #2 + #1{1, 0}, Throw[False]] &, > {1, 1}First@t, Rest@t]; True] > >Bobby > >On Sat, 5 Apr 2003 04:00:35 -0500 (EST), flip ><flip_alpha at safebunch.com> >wrote: > >> Hello, >> >> does a command or module exist which can test a list of values and >> determine >> if it is a super-increasing list? >> >> A super-increasing list satifies the conditions: >> >> a. the list is in increasing order >> b. each element of the list is greater than the sum of it's previous >> elements >> >> Example: >> >> list = {2, 3, 7, 15, 31} >> >> So check: >> >> a. It is in increasing order and >> b. 3 > 2, 7 > 3+ 2, 15 > 7 + 3 + 2 and 31 > 15 + 7 + 3 + 2, >> >> hence the list is super-increasing. >> >> Thanks for any inputs, Flip >> >> To email me, remove "_alpha". >> >> >> >> > > > >-- >majort at cox-internet.com >Bobby R. Treat > >