package main;

class BitManipulator {
    static int insertBitsToPosition(int n, int m, int i, int j) {
        int left = ~0 << j;
        int right = (1 << i-1) - 1;
        int mask = left | right;
        int nCleared = n & mask;
        int mShifted = m << i-1;
        return nCleared | mShifted;
    }
}

package main;

class BitManipulator {
    static int insertBitsToPosition(int n, int m, int i, int j) {
        return (n & ((~0 << j) | ((1 << i-1) - 1))) | (m << i-1);
    }
}

Refactor solution for 5.1 to 1-line transofrmation function. Note: it takes less space but almost unreadable for human.
Refactor solution for 5.1 to 1-line transofrmation function. Note: it
takes less space but almost unreadable for human.
