I have n number of one-dimensional arrays similar to:
[0,0,0,0,0,1,1,1,0,0,1,1,...]
0's and 1's indicating occupation.
And k number of smaller arrays similar to:
[2,2,2], [2,2], [2], [2,2,2,2]
with varying sizes. What I want to do is to see where and how I can fit the smaller (second) arrays to bigger arrays following each other buy indexes. Example:
Domain Arrays:
[0000111001]
[0011011001]
[0011100001]
[0000100001]
Smaller Arrays:
[22]
[2]
[222]
Result:
[0020111001]
[2211011001]
[0012220001]
[0000100001]
or
[0000111001]
[0011011001]
[0012200001]
[0020122201]
I hope I could put it into words well.
My solution is:
Finding empty spots that can fit any of the smaller arrays. And creating a tree with possible combinations like;
1-First small array goes to second big arrays 3rd index and occupies 3 spaces 2-Second small array goes to first big arrays 7th index and occupies 4 spaces
etc.
and I get the patterns of every branch on the tree with depth of smaller array count. But it of course works slowly. Which algorithms can I use to solve this problem? Thank you in advance.