Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6627 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2011-11-22 10:45 +0000 |
| Last post | 2011-11-22 10:45 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Loop problem Bob Hanlon <hanlonr357@gmail.com> - 2011-11-22 10:45 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2011-11-22 10:45 +0000 |
| Subject | Re: Loop problem |
| Message-ID | <jafuh5$rtb$1@smc.vnet.net> |
For i!=j!=k!=l, I assume that you mean that there must be four
distinct elements and that for this and the other cases that you must
mean 0 <= i,j,k,l <= 3
Select[Tuples[Range[0, 3], 4], Length[Union[#]] == 4 &]
{{0, 1, 2, 3}, {0, 1, 3, 2}, {0, 2, 1, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}, {0, 3,
2, 1}, {1, 0, 2, 3}, {1, 0, 3, 2}, {1, 2, 0, 3}, {1, 2, 3, 0}, {1, 3, 0,
2}, {1, 3, 2, 0}, {2, 0, 1, 3}, {2, 0, 3, 1}, {2, 1, 0, 3}, {2, 1, 3,
0}, {2, 3, 0, 1}, {2, 3, 1, 0}, {3, 0, 1, 2}, {3, 0, 2, 1}, {3, 1, 0,
2}, {3, 1, 2, 0}, {3, 2, 0, 1}, {3, 2, 1, 0}}
For i!=j=k!=l, I assume that you want three distinct elements with
positions 2 and 3 equal
Select[Tuples[Range[0, 3], 4], #[[2]] == #[[3]] && Length[Union[#]] == 3 &]
{{0, 1, 1, 2}, {0, 1, 1, 3}, {0, 2, 2, 1}, {0, 2, 2, 3}, {0, 3, 3, 1}, {0, 3,
3, 2}, {1, 0, 0, 2}, {1, 0, 0, 3}, {1, 2, 2, 0}, {1, 2, 2, 3}, {1, 3, 3,
0}, {1, 3, 3, 2}, {2, 0, 0, 1}, {2, 0, 0, 3}, {2, 1, 1, 0}, {2, 1, 1,
3}, {2, 3, 3, 0}, {2, 3, 3, 1}, {3, 0, 0, 1}, {3, 0, 0, 2}, {3, 1, 1,
0}, {3, 1, 1, 2}, {3, 2, 2, 0}, {3, 2, 2, 1}}
For i!=j!=k=l, I assume that you want three distinct elements with
positions 3 and 4 equal
Select[Tuples[Range[0, 3], 4], #[[3]] == #[[4]] && Length[Union[#]] == 3 &]
{{0, 1, 2, 2}, {0, 1, 3, 3}, {0, 2, 1, 1}, {0, 2, 3, 3}, {0, 3, 1, 1}, {0, 3,
2, 2}, {1, 0, 2, 2}, {1, 0, 3, 3}, {1, 2, 0, 0}, {1, 2, 3, 3}, {1, 3, 0,
0}, {1, 3, 2, 2}, {2, 0, 1, 1}, {2, 0, 3, 3}, {2, 1, 0, 0}, {2, 1, 3,
3}, {2, 3, 0, 0}, {2, 3, 1, 1}, {3, 0, 1, 1}, {3, 0, 2, 2}, {3, 1, 0,
0}, {3, 1, 2, 2}, {3, 2, 0, 0}, {3, 2, 1, 1}}
For i!=k!=j=l , I assume that you want three distinct elements with
positions 2 and 4 equal
Select[Tuples[Range[0, 3], 4], #[[2]] == #[[4]] && Length[Union[#]] == 3 &]
{{0, 1, 2, 1}, {0, 1, 3, 1}, {0, 2, 1, 2}, {0, 2, 3, 2}, {0, 3, 1, 3}, {0, 3,
2, 3}, {1, 0, 2, 0}, {1, 0, 3, 0}, {1, 2, 0, 2}, {1, 2, 3, 2}, {1, 3, 0,
3}, {1, 3, 2, 3}, {2, 0, 1, 0}, {2, 0, 3, 0}, {2, 1, 0, 1}, {2, 1, 3,
1}, {2, 3, 0, 3}, {2, 3, 1, 3}, {3, 0, 1, 0}, {3, 0, 2, 0}, {3, 1, 0,
1}, {3, 1, 2, 1}, {3, 2, 0, 2}, {3, 2, 1, 2}}
Bob Hanlon
On Mon, Nov 21, 2011 at 4:27 AM, P Shar <puya.sharif@live.com> wrote:
> Hey guys, i need a loop (that does the following) and can't figure out what to do..
>
> I need a set of lists {i,j,k,l} i=E2=89 j=E2=89 k=E2=89 l, i=E2=89 j=k=E2=89 l, i=E2=89 j=E2=89 k=l, i=E2=89 k=E2=89 j=l where 0 < i,j,k,l < 3.
>
> So basically all the cases where the first condition holds and all the cases there the second holds etc..
>
> Easiest would be to get the output as a matrix with the {i,j,k,l}'s as rows.
>
> Any ideas (or at least where to start)?
>
> Cheers
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web