How to create groups of equal sizes from an array having a single row of integer values?
3 views (last 30 days)
Show older comments
I have an array of integer values as eg.
A= [78, 97, 116, 105, 111, 110, 97, 108, 32, 73, 110, 115, 116, 105, 116, 117, 116,101, 32, 111, 102, 32, 84, 101, 99, 104, 110, 111, 108, 111, 103, 121, 44, 32, 77, 97, 110, 105, 112, 117, 114, 44,
32, 55, 57, 53, 48, 48, 49, 32, 40, 69, 110, 103, 108]
I want to determine how many groups of equal size are possible from above array and split the array accordingly. Last group may contain numbers less than group size. P.S - Actual array contains many more numbers than above array. Any help would be greatly appreciated.
0 Comments
Answers (1)
Walter Roberson
on 27 Feb 2018
For each possible permutation of A, you can split the permutation every 1 item, every 2 items, every 3 items, ... all length(A) items.
The number of permutations of A is length(A) and there are length(A) different sizes of groups to split into, so the total number of (ordered) groups will be factorial(length(A))*length(A) . This would have to be reduced if some of the items are identical (which does turn out to be the case for your data.)
So you are looking at 55!*55 which is about 6.9E74 as your starting point. You certainly would not have less than length(unique(A))*length(A) as your base number, which would give you at least 4.8E32
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!