Jump to content

Combination of elements


dumbledor
 Share

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

Link to comment
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)
                    _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
Link to comment
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)
                    _ArrayAdd($array, $sy&","&$sz&","&$si&","&$sj&","&$sk)
            EndIf
Next
Next
Next
Next
Next

_ArrayDisplay($array)

Not sure this is what you want ...

Cheers, FireFox.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...