Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi there
I have a two-dimensional array with 53 "rows" and 11 "columns". The array values are either "1" or "0", indicating whether a person is working ("1") or not-working ("0") during each of 11 hourly shifts in a day. The 53 rows represent different ways in which a person could work. For instance, concatenating one row of the array yields a string of "01111000000", which indicates that a person is scheduled to work 4 consecutive hours (ie. the 4 "1"s) from the second hour of the day (ie. the position of the first "1", in this case 9am). The 53 permutations are not complete: some have been excluded since they don't represent a realistic work pattern. For example, the string "01010101010" represents too uneven a pattern of work, while the string "01000000010" presents too big a stretch between the person's two shifts. Two questions arise: Firstly, how can I use a VBA procedure to generate all possible permutations for two, three, four and more people? (Am I right to say that the total number of permutations for n people is 53^n? If so, then the number of permutations expands rapidly: 53; 2,809; 148,877; 7,890,481; and so on. Nonetheless I need to write the different permutations out.) Secondly, how do I generate only the distinct permutations? For instance, in the case n=2, there are 2,809 (=53^2) permutations but there are only 1,481 (=53+52+51+50+...+1) distinct permutations. If I'm right, to get only the distinct permutations, I add the values in each "row" of the original array (ie. case n=1) to each row in the array for case n=k, omitting the case k=n. Any suggestions would be gratefully appreciated! Best regards Loane |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If there are 53 feasible work patterns and you want to see how many unique
ways you can pair two of them (two workers), then =combin(53,2) = 1378 this assumes that they can not work an identical shift. If they can, then there would be 53 more combinations. likewise for 3 people =combin(53,3) = 23,426 4 =combin(53,4) = 292,825 and so forth. You say you want to generate them, so where do you want to put the output and in what format? do you want 1,2 to indicate array item 1 (work pattern 1) paired with array item 2 (work pattern 2) as an output. Or do you want 11 cells times 2 rows written to a worksheet. -- Regards, Tom Ogilvy "Loane Sharp" wrote in message ... Hi there I have a two-dimensional array with 53 "rows" and 11 "columns". The array values are either "1" or "0", indicating whether a person is working ("1") or not-working ("0") during each of 11 hourly shifts in a day. The 53 rows represent different ways in which a person could work. For instance, concatenating one row of the array yields a string of "01111000000", which indicates that a person is scheduled to work 4 consecutive hours (ie. the 4 "1"s) from the second hour of the day (ie. the position of the first "1", in this case 9am). The 53 permutations are not complete: some have been excluded since they don't represent a realistic work pattern. For example, the string "01010101010" represents too uneven a pattern of work, while the string "01000000010" presents too big a stretch between the person's two shifts. Two questions arise: Firstly, how can I use a VBA procedure to generate all possible permutations for two, three, four and more people? (Am I right to say that the total number of permutations for n people is 53^n? If so, then the number of permutations expands rapidly: 53; 2,809; 148,877; 7,890,481; and so on. Nonetheless I need to write the different permutations out.) Secondly, how do I generate only the distinct permutations? For instance, in the case n=2, there are 2,809 (=53^2) permutations but there are only 1,481 (=53+52+51+50+...+1) distinct permutations. If I'm right, to get only the distinct permutations, I add the values in each "row" of the original array (ie. case n=1) to each row in the array for case n=k, omitting the case k=n. Any suggestions would be gratefully appreciated! Best regards Loane |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
permutations | Excel Worksheet Functions | |||
Permutations | Excel Discussion (Misc queries) | |||
permutations | Excel Discussion (Misc queries) | |||
Permutations | Excel Worksheet Functions | |||
Permutations | Excel Worksheet Functions |