[Date Index]
[Thread Index]
[Author Index]
Re: List manipulation question - 2013
*To*: mathgroup at smc.vnet.net
*Subject*: [mg129636] Re: List manipulation question - 2013
*From*: Lea Rebanks <lrebanks at gmail.com>
*Date*: Fri, 1 Feb 2013 01:15:53 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: l-mathgroup@wolfram.com
*Delivered-to*: mathgroup-newout@smc.vnet.net
*Delivered-to*: mathgroup-newsend@smc.vnet.net
*References*: <20130130092653.09BA46877@smc.vnet.net>
Hi Bob,
This is excellent, really impressive & works a dream.
However, I did notice that a certain number of combinations of inputs for a
& b do not provide a result at all, which was a surprise.
For example :- f[19, 8, 6] does not provide a result or any multiple of 8
for b value.
Is this TRUE that certain combinations of integers here should not provide
a result?
Many thanks for your help. Really appreciated.
Best regards,
Lea...
On Fri, Feb 1, 2013 at 9:47 AM, Bob Hanlon <hanlonr357 at gmail.com> wrote:
> Clear[f]
>
> f[a_, b_, outputLen_: (-1), c_: 2000] :=
> Module[{list1, list2},
> list1 = Table[24 + (a*n1), {n1, c}];
> list2 = Select[list1, IntegerQ[#/24] &];
> list3 = Last /@
> (Select[
> Solve[{12 + (b*n2) == #,
> Element[n2, Integers]}, n2] & /@
> list2,
> Length[#] > 0 &] // Flatten);
> If[outputLen == -1,
> list3,
> list3[[1 ;; Min[outputLen, Length[list3]]]]]];
>
> f[15, 3, 6]
>
> {44, 84, 124, 164, 204, 244}
>
> f[13, 7, 6]
>
> {180, 492, 804, 1116, 1428, 1740}
>
>
> Bob Hanlon
>
>
> On Thu, Jan 31, 2013 at 2:56 AM, Lea Rebanks <lrebanks at gmail.com> wrote:
> > Hi Bob,
> >
> > Many thanks for your excellent reply.
> > Your coding for lists 1,2,3 is exactly what I want.
> > And your statement - "Apparently you want list2 to consist of the
> members of
> > list1 that are
> > integer multiples of 24 rather than the integers in list1/24." is
> correct.
> >
> > But I tried changing the input values from the example given
> > From 24 + (15*n1) to 24 + (13*n1) .....15 to 13
> > From 12 + (3*n2) to 12 + (7*n2) .....3 to 7
> > This immediately caused me error messages, some of which I was able to
> > correct by expanding the list range of the Take function.
> > But I was unable to calculate the last part for list3 :-
> >
> > list1 = Table[24 + (13*n1), {n1, 2000}];
> > list2 = Take[Select[list1, IntegerQ[#/24] &], 40];
> > list3 = n2 /.
> > Solve[{12 + (7*n2) == #, Element[n2, Integers]}, n2][[1]] & /@
> > list2
> >
> > Hopefully the result should look something like :-
> > {1272, 3456, 5640, 7824, 10008, 12192}
> > These values above being the first & then following repetitions
> thereafter
> > of equal points of repetitions of n1 & n2 in list2 & list3 respectively.
> >
> > Please could you rewrite the enclosed code so that :-
> > (i) The above new values work & provide a similar result to that which I
> > have shown.
> > (ii) Also, if possible, allow in the rewrite the flexibility within the
> > function to accept much larger & challenging input values for list1 & 2.
> > This would include a domain allowance relative to the size of input
> values
> > as in this case its values are 13 & 7, but they could be integer values
> of
> > 127 & 56 for list1 & list3 respectively.
> > (Note higher value first.) Actually I will probably want to use much much
> > higher values later.
> > Ideally I am only looking for about 6 elements in the final answer list
> like
> > - {1272, 3456, 5640, 7824, 10008, 12192}
> >
> > Many thanks for your help & attention.
> > Really appreciated.
> > Best regards,
> > Lea...
> >
> >
> >
> >
> > On Thu, Jan 31, 2013 at 11:05 AM, Bob Hanlon <hanlonr357 at gmail.com>
> wrote:
> >>
> >> list1 = Table[24 + (15*n1), {n1, 2000}];
> >>
> >> Take[Select[list1/24, IntegerQ], 9]
> >>
> >> {6, 11, 16, 21, 26, 31, 36, 41, 46}
> >>
> >> Take[Select[list1, IntegerQ[#/24] &], 9]
> >>
> >> {144, 264, 384, 504, 624, 744, 864, 984, 1104}
> >>
> >> Apparently you want list2 to consist of the members of list1 that are
> >> integer multiples of 24 rather than the integers in list1/24.
> >>
> >> list2 = Select[list1, IntegerQ[#/24] &];
> >>
> >> list3 = n2 /. Solve[
> >> {12 + (3*n2) == #, Element[n2, Integers]},
> >> n2][[1]] & /@ list2;
> >>
> >> Length[list2] == Length[list3]
> >>
> >> True
> >>
> >>
> >> Bob Hanlon
> >>
> >> Consequently, there is an integer n2 for every element of list2.
> >>
> >> On Wed, Jan 30, 2013 at 4:26 AM, Lea Rebanks <lrebanks at gmail.com>
> wrote:
> >> >
> >> > Dear All,
> >> >
> >> > I have the follow problem with the combination of a few lists.
> >> > I shall outline the problem or what I am trying to do.
> >> > I know that to solve this problem requires a number of processes, but
> I
> >> > am
> >> > not sure how to setup the coding to achieve my desired result.
> >> > Please could someone show me the coding for this problem.
> >> >
> >> > The problem:-
> >> > 1 - I have a list1 created from 24+(15*n1) All n1 are integers
> >> > 1,2,3,4.....to a large number of integers.
> >> > 2 - I want to divide the list1 by 24 and create another list2 with
> only
> >> > the
> >> > integer results in list2.
> >> > Table[24 + 15*i, {i, 100}]/24 ... so that integer results in
> >> > list2
> >> > = { 144, 264, 384, 504, 624, 744, 864, 984, 1104 }
> >> > 3 - I have another list3 created from 12+(3*n2) All n2 are integers
> >> > 1,2,3,4.....to a large number of integers.
> >> > 4 - With list3 I want to find :-
> >> > (i) The integer number of n2 that either equates 12+(3*n2) = 144
> or
> >> > the next FIRST available number in list2 that meets this equality.
> >> > then also (ii)The integer number(s) of n2 that equates 12+(3*n2) =
> >> > 24+(15*n1) after the first equal value for say 6 repetitions.
> >> > then also (iii)The integer number(s) of n1 that equates
> 12+(3*n2) =
> >> > 24+(15*n1) after the first equal value for say 6 repetitions.
> >> >
> >> > The above example is quite simple, but I am hoping to setup the coding
> >> > to
> >> > work with other integer values instead of 3 & 15 which will present
> more
> >> > of
> >> > a challenge.
> >> >
> >> > Any help or advice greatly appreciated.
> >> > Best regards,
> >> > Lea...
> >> >
> >> >
> >>
> >
>
>
Next by Date:
**Re: Euclidean distance of all pairwise combinations (redundants)**
Next by thread:
**Re: Euclidean distance of all pairwise combinations (redundants)**
| |