Re: Loop problem

• To: mathgroup at smc.vnet.net
• Subject: [mg123049] Re: Loop problem
• From: Ray Koopman <koopman at sfu.ca>
• Date: Tue, 22 Nov 2011 05:32:23 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```On Nov 21, 1:34 am, P Shar <puya.sha... at 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

0 < i,j,k,l < 3 means that each of i,j,k,l must be either 1 or 2.
I assume you want 0 <= i,j,k,l <= 3.

I assume that i=E2=89 j=E2=89 k=E2=89 l means  Unequal[i,j,k,l],
not merely  Unequal[i,j] && Unequal[j,k] && Unequal[k,l].

I assume that i=E2=89 j=k=E2=89 l means  Unequal[i,j,l] && Equal[j,k],
and similarly for the conditions 3 and 4.

Condition 1 is straightforward:

Permutations@Range[0,3]

{{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}}

Condition 2 is more convoluted:

Join@@Permutations/@Subsets[Range[0,3],{3}]/.{a_,b_,c_}->{a,b,b,c}

{{0,1,1,2},{0,2,2,1},{1,0,0,2},{1,2,2,0},{2,0,0,1},{2,1,1,0},
{0,1,1,3},{0,3,3,1},{1,0,0,3},{1,3,3,0},{3,0,0,1},{3,1,1,0},
{0,2,2,3},{0,3,3,2},{2,0,0,3},{2,3,3,0},{3,0,0,2},{3,2,2,0},
{1,2,2,3},{1,3,3,2},{2,1,1,3},{2,3,3,1},{3,1,1,2},{3,2,2,1}}

For condition 3, change {a,b,b,c} to {a,b,c,c}.
For condition 4, change {a,b,b,c} to {a,b,c,b}.

```

• Prev by Date: Re: problem in minimization of a matrix
• Next by Date: Re: Elliptical gear calculations
• Previous by thread: Re: Loop problem
• Next by thread: Re: Loop problem
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://forums.wolfram.com/mathgroup/archive/2011/Nov/msg00500.html", "fetch_time": 1586419924000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2020-16/segments/1585371830894.88/warc/CC-MAIN-20200409055849-20200409090349-00394.warc.gz", "warc_record_offset": 67614455, "warc_record_length": 7874, "token_count": 950, "char_count": 2055, "score": 3.734375, "int_score": 4, "crawl": "CC-MAIN-2020-16", "snapshot_type": "longest", "language": "en", "language_score": 0.7264615297317505, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00060-of-00064.parquet"}