private static void getPermutations (Adder add, int size, int ops_count) {
        int[] ops = new int[size];
        Arrays.fill(ops, -1);
        int[] ops_pos = new int[ops_count];
        Arrays.fill(ops_pos, -1);
        int ops_used = 0;
        int i = 0;
        while (true) {
            if (i < 0) {
                break;
            } else if (i == size) {
                add.add(ops);
                i--;
            } else {
                if (ops[i] != -1 && ops_pos[ops[i]] == i) {
                    ops_pos[ops[i]] = -1;
                    ops_used--;
                }
                ops[i]++;
                if (ops[i] == ops_count) {
                    ops[i] = -1;
                    i--;
                } else {
                    if (ops_pos[ops[i]] == -1) {
                        ops_pos[ops[i]] = i;
                        ops_used++;
                    }
                    if ((ops_count - ops_used) < (size - i)) {
                        i++;
                    }
                }
            }
        }
    }