# Combination of elements

## Recommended Posts

Hello!

I have written this script:

```#include<array.au3>

\$si=1
\$sj=1
\$sk=1
\$sz=1
\$sy=1
local \$array[1]

Do
Do
Do
Do
Do
if \$sk <> \$si Then
if \$sk <> \$sj Then
if \$si <> \$sj Then
If \$sz <> \$sj Then
If \$sz <> \$si Then
If \$sz <> \$sk Then
If \$sy <> \$si Then
If \$sy <> \$sj Then
If \$sy <> \$sk Then
If \$sy <> \$sz Then
ConsoleWrite( \$sy&","&\$sz&","&\$si&","&\$sj&","&\$sk&@crlf)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
\$sk = \$sk+1
Until \$sk == 7
\$sk = 1
\$sj = \$sj+1
until \$sj == 7
\$sj = 1
\$si = \$si +1
Until \$si == 7
\$si = 1
\$sz = \$sz +1
Until \$sz == 7
\$sz = 1
\$sy = \$sy + 1
Until \$sy ==7

_ArrayDisplay(\$array)```

Script is doing what it should do (making combinations of 5 elements between 6) but i want to make it better looking. Anybody has any idea, how to make it shorter? More visible?

##### Share on other sites

@dumbledoor

Here we go :

```#include<array.au3>

Local \$si=1, \$sj=1, \$sk=1, \$sz=1, \$sy=1, \$array[1]

Do
Do
Do
Do
Do
if \$sk <> \$si and \$sk <> \$sj And \$si <> \$sj And \$sz <> \$sj And \$sz <> \$si And \$sz <> \$sk And \$sy <> \$si And \$sy <> \$sj And \$sy <> \$sk And \$sy <> \$sz Then
ConsoleWrite( \$sy&","&\$sz&","&\$si&","&\$sj&","&\$sk&@crlf)
EndIf
\$sk = \$sk+1
Until \$sk == 7
\$sk = 1
\$sj = \$sj+1
until \$sj == 7
\$sj = 1
\$si = \$si +1
Until \$si == 7
\$si = 1
\$sz = \$sz +1
Until \$sz == 7
\$sz = 1
\$sy = \$sy + 1
Until \$sy ==7

_ArrayDisplay(\$array)```

Of course this can be better but i can test it now

Cheers, FireFox.

Script is doing what it should do (making combinations of 5 elements between 6) but i want to make it better looking. Anybody has any idea, how to make it shorter? More visible?

Edited by FireFox

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

##### Share on other sites

@dumbledoor

Another way :

```#include<array.au3>

Local \$si=1, \$sj=1, \$sk=1, \$sz=1, \$sy=1, \$array[1]

For \$nb = 1 to 7
For \$nb = 1 to 7
For \$nb = 1 to 7
For \$nb = 1 to 7
For \$nb = 1 to 7
if \$sk <> \$si and \$sk <> \$sj And \$si <> \$sj And \$sz <> \$sj And \$sz <> \$si And \$sz <> \$sk And \$sy <> \$si And \$sy <> \$sj And \$sy <> \$sk And \$sy <> \$sz Then
ConsoleWrite( \$sy&","&\$sz&","&\$si&","&\$sj&","&\$sk&@crlf)
EndIf
Next
Next
Next
Next
Next

_ArrayDisplay(\$array)```

Not sure this is what you want ...

Cheers, FireFox.

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

##### Share on other sites

I don't know if this is a script or you need help.

When the words fail... music speaks

##### Share on other sites

... or better _ArrayCombinations

No need to reinvent the wheel

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

## Create an account

Register a new account