diff options
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -726,14 +726,14 @@ void combinations_with_replacement(size_t n, size_t r, size_t *result, size_t *l size_t i, j; size_t *tmp; - tmp = malloc(sizeof(size_t)*n*ipow(n,r)); + tmp = malloc(sizeof(size_t)*r*ipow(n,r)); product(n,r,tmp); *len = 0; for (i = 0; i < ipow(n,r); i++) { if (is_sorted(tmp+i*r,r)) { - for (j = 0; j < n; j++) { + for (j = 0; j < r; j++) { result[(*len)*r+j] = tmp[i*r+j]; } *len += 1; |