Вот способ получить все возможные решения.
library(partitions)
allPartitions <- compositions(10, 6, include.zero = FALSE)
limits <- c(1, 2, 5, 6, 7, 6)
good <- apply(allPartitions, 2, function(x) all(x <= limits))
results <- allPartitions[, good]
> t(results)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 2 4 1 1 1
[2,] 1 1 5 1 1 1
[3,] 1 2 3 2 1 1
[4,] 1 1 4 2 1 1
[5,] 1 2 2 3 1 1
[6,] 1 1 3 3 1 1
[7,] 1 2 1 4 1 1
[8,] 1 1 2 4 1 1
[9,] 1 1 1 5 1 1
[10,] 1 2 3 1 2 1
[11,] 1 1 4 1 2 1
[12,] 1 2 2 2 2 1
[13,] 1 1 3 2 2 1
[14,] 1 2 1 3 2 1
[15,] 1 1 2 3 2 1
[16,] 1 1 1 4 2 1
[17,] 1 2 2 1 3 1
[18,] 1 1 3 1 3 1
[19,] 1 2 1 2 3 1
[20,] 1 1 2 2 3 1
[21,] 1 1 1 3 3 1
[22,] 1 2 1 1 4 1
[23,] 1 1 2 1 4 1
[24,] 1 1 1 2 4 1
[25,] 1 1 1 1 5 1
[26,] 1 2 3 1 1 2
[27,] 1 1 4 1 1 2
[28,] 1 2 2 2 1 2
[29,] 1 1 3 2 1 2
[30,] 1 2 1 3 1 2
[31,] 1 1 2 3 1 2
[32,] 1 1 1 4 1 2
[33,] 1 2 2 1 2 2
[34,] 1 1 3 1 2 2
[35,] 1 2 1 2 2 2
[36,] 1 1 2 2 2 2
[37,] 1 1 1 3 2 2
[38,] 1 2 1 1 3 2
[39,] 1 1 2 1 3 2
[40,] 1 1 1 2 3 2
[41,] 1 1 1 1 4 2
[42,] 1 2 2 1 1 3
[43,] 1 1 3 1 1 3
[44,] 1 2 1 2 1 3
[45,] 1 1 2 2 1 3
[46,] 1 1 1 3 1 3
[47,] 1 2 1 1 2 3
[48,] 1 1 2 1 2 3
[49,] 1 1 1 2 2 3
[50,] 1 1 1 1 3 3
[51,] 1 2 1 1 1 4
[52,] 1 1 2 1 1 4
[53,] 1 1 1 2 1 4
[54,] 1 1 1 1 2 4
[55,] 1 1 1 1 1 5
Или, более кратко и, возможно, более эффективно:
> results <- sweep(blockparts(limits-1,10-6), 1, c(1,1,1,1,1,1), "+")
> t(results)
[1,] 1 2 4 1 1 1
[2,] 1 1 5 1 1 1
[3,] 1 2 3 2 1 1
[4,] 1 1 4 2 1 1
[5,] 1 2 2 3 1 1
[6,] 1 1 3 3 1 1
[7,] 1 2 1 4 1 1
[8,] 1 1 2 4 1 1
[9,] 1 1 1 5 1 1
[10,] 1 2 3 1 2 1
[11,] 1 1 4 1 2 1
[12,] 1 2 2 2 2 1
[13,] 1 1 3 2 2 1
[14,] 1 2 1 3 2 1
[15,] 1 1 2 3 2 1
[16,] 1 1 1 4 2 1
[17,] 1 2 2 1 3 1
[18,] 1 1 3 1 3 1
[19,] 1 2 1 2 3 1
[20,] 1 1 2 2 3 1
[21,] 1 1 1 3 3 1
[22,] 1 2 1 1 4 1
[23,] 1 1 2 1 4 1
[24,] 1 1 1 2 4 1
[25,] 1 1 1 1 5 1
[26,] 1 2 3 1 1 2
[27,] 1 1 4 1 1 2
[28,] 1 2 2 2 1 2
[29,] 1 1 3 2 1 2
[30,] 1 2 1 3 1 2
[31,] 1 1 2 3 1 2
[32,] 1 1 1 4 1 2
[33,] 1 2 2 1 2 2
[34,] 1 1 3 1 2 2
[35,] 1 2 1 2 2 2
[36,] 1 1 2 2 2 2
[37,] 1 1 1 3 2 2
[38,] 1 2 1 1 3 2
[39,] 1 1 2 1 3 2
[40,] 1 1 1 2 3 2
[41,] 1 1 1 1 4 2
[42,] 1 2 2 1 1 3
[43,] 1 1 3 1 1 3
[44,] 1 2 1 2 1 3
[45,] 1 1 2 2 1 3
[46,] 1 1 1 3 1 3
[47,] 1 2 1 1 2 3
[48,] 1 1 2 1 2 3
[49,] 1 1 1 2 2 3
[50,] 1 1 1 1 3 3
[51,] 1 2 1 1 1 4
[52,] 1 1 2 1 1 4
[53,] 1 1 1 2 1 4
[54,] 1 1 1 1 2 4
[55,] 1 1 1 1 1 5