Jump to content
Sign in to follow this  
dumbledor

Combination of elements

Recommended Posts

dumbledor

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)
                    _ArrayAdd($array, $sy&","&$sz&","&$si&","&$sj&","&$sk)
                                                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?

Thanks in advance.

Share this post


Link to post
Share on other sites
FireFox

@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)
                    _ArrayAdd($array, $sy&","&$sz&","&$si&","&$sj&","&$sk)
            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?

Thanks in advance.

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 this post


Link to post
Share on other sites
FireFox

@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)
                    _ArrayAdd($array, $sy&","&$sz&","&$si&","&$sj&","&$sk)
            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 this post


Link to post
Share on other sites
Andreik

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

Anyway, read in help file about _ArrayPermute().


When the words fail... music speaks

Share this post


Link to post
Share on other sites
enaiman

... 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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×