Jump to content

all possible cominations using 1 value


Recommended Posts

hello world :)

i have been looking through different examples of permutations but have not been able to find one which allows a required value

hope example makes sense

$master_value = "Z"

Global $value_list[4] = ["A", "B", "C", "D"]

so the possible combinations would be something like this (all would include the "master value")

Quote

 

Z,A

A,Z

Z,B

B,Z

Z,C

C,Z

Z,D

D,Z

Z,A,B

Z,B,A

A,Z,B

B,Z,A

B,A,Z

A,B,Z

Z,A,B,C

Z,B,C,A

Z,C,B,A

......

 

thank you in advance!

 

Link to comment
Share on other sites

I am asking on a method on how to accomplish what i described.  Users are picking a business role and I'd like to be able to go through a list of other business role values (defined by the user) to store all possible combinations to an array which will later be used as possible filters in a check list.  Hope that makes sense

Link to comment
Share on other sites

Spoon-feeding will probably shorten this thread.

Local $master_value = "Z"
Local $value_list = ["A", "B", "C", "D"]
Local $a, $aa, $aRes[0]

For $i = 1 To UBound($value_list)
    $a = _ArrayCombinations($value_list, $i)
    _ArrayDelete($a, 0)
    For $j = 0 To UBound($a) - 1
        $aa = _ArrayPermute(StringSplit($a[$j] & $master_value, "", 3), ',')
        _ArrayDelete($aa, 0)
        _ArrayAdd($aRes, $aa)
    Next
Next
$ad($aRes)

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

<*snip - all wrong and would only serve to confuse, plus maybe not supposed to be helping yet>

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I remember when I started at this site, mods were blasting me about providing code without at least a first effort from the OP.  Now I understand what is the concept of variable geometry...

Edited by Nine
Link to comment
Share on other sites

tbf, gcue has like 2100 posts worth of effort.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

@Nine, Some OPs have a record of making threads long lasting...

@iamtheky, the first code misses some combinations, e.g. BZ, CZ, ABDZ, ...

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

@iamtheky the second code has the same issue as your first.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

yup, they both do. 

I had a feeling getting rid of the second loop wasnt going to be that easy.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

1 minute ago, jchd said:

Some OPs have a record of making threads long lasting...

So what is the problem with that ?

3 minutes ago, iamtheky said:

tbf, gcue has like 2100 posts worth of effort.

Effort ?  With 9+, asking for code repeatedly is not what I would call it.

Link to comment
Share on other sites

@Jos, sorry for that!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

really by the +'s ?  I've been judging people by their warning points, and by height.

and also i was following the badged guy, and my answers were wrong anyway :)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Developers
10 hours ago, jchd said:

Spoon-feeding will probably shorten this thread.

Local $master_value = "Z"
Local $value_list = ["A", "B", "C", "D"]
Local $a, $aa, $aRes[0]

For $i = 1 To UBound($value_list)
    $a = _ArrayCombinations($value_list, $i)
    _ArrayDelete($a, 0)
    For $j = 0 To UBound($a) - 1
        $aa = _ArrayPermute(StringSplit($a[$j] & $master_value, "", 3), ',')
        _ArrayDelete($aa, 0)
        _ArrayAdd($aRes, $aa)
    Next
Next
$ad($aRes)

 

Not sure whether this will be considered spoon-feeding as the food isn't ready yet and still contains "uncooked bits". ;) 

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Yeah, some chunks might need some chewing 🐅

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

15 hours ago, iamtheky said:

really by the +'s ?  I've been judging people by their warning points, and by height.

Bah. Just place some jokes and you will get a lot of +'s . Not significant

BTW you should like this alternative, based on simple String* funcs only  :)

#Include <Array.au3>

Global $master = "Z", $text[5] = ["A", "B", "C", "D", $master], $s = ""

_LetsGo("")
$a = StringSplit(StringTrimRight($s, 1), "|", 2)
_ArrayDisplay($a)

Func _LetsGo($string)
   For $i = 0 to UBound($text)-1
       If not StringInStr($string, $text[$i]) Then 
            $tmp = $string & "," & $text[$i] 
            If StringInStr($tmp , $master) and StringLen($tmp)>2 Then 
               $s &= StringTrimLeft($tmp, 1) & "|"
           EndIf
            _LetsGo($tmp)
       EndIf
   Next
EndFunc

 

Edited by mikell
Link to comment
Share on other sites

Needs more chewing :evil:

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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