You can use a loop to generate possible layer combinations ranging from 5 to 25 layers while satisfying the constraints. Here's an example code:
main.m605 chars16 lines
This code first generates all possible layer combinations for each number of layers in the given range using dec2bin
and binary subtraction. It then applies the constraint by using conv2
to count the number of consecutive 1s (i.e., 45 degree layers) within a rolling window of length max_45deg_streak
. If any such streak is longer than the maximum allowed, the combination is flagged as invalid.
The code prints the valid combinations for each number of layers, but you can modify it for your specific use case.
gistlibby LogSnag