package util;

import java.util.BitSet;
import java.util.stream.IntStream;

public class Util {

    public static BitSet concatenateBitStrings(BitSet leftBitString, BitSet rightBitString, int n) {
        long left = (leftBitString.length() != 0) ? leftBitString.toLongArray()[0] : 0;
        long right = (rightBitString.length() != 0) ? rightBitString.toLongArray()[0] : 0;
        long concatenated = (left << n/2) | right;
        return BitSet.valueOf(new long[]{concatenated});
    }

    public static String convertBitSetToString(BitSet bitString, int n) {
        final StringBuilder buffer = new StringBuilder(n);
        IntStream.range(0, n)
                .map(i -> n - i - 1)
                .mapToObj(i -> bitString.get(i) ? '1' : '0')
                .forEach(buffer::append);
        return buffer.toString();
    }

    public static int bitSetToInt(BitSet bitSet) {
        int num = 0, i = 0;

        while (true) {
            i = bitSet.nextSetBit(i);
            if(i < 0) break;
            num |= (1 << i);
            i++;
        }

        num &= Integer.MAX_VALUE;
        return num;
    }

}

@@ -148,25 +148,16 @@
 Set left
-BitString
 , BitSet
@@ -162,25 +162,16 @@
 et right
-BitString
 , int n)
@@ -185,285 +185,195 @@
     
-long left = (leftBitString.length() != 0) ? leftBitString.toLongArray()%5B0%5D : 0;%0A        long right = (rightBitString.length() != 0) ? rightBitString.toLongArray()%5B0%5D : 0;%0A        long concatenated = (left %3C%3C n/2) %7C right;%0A        return BitSet.valueOf(new long%5B%5D%7Bconcatenated%7D)
+BitSet total = new BitSet(n);%0A%0A        for(int i = 0; i %3C n/2 ; i++) %7B%0A            total.set(i, right.get(i));%0A            total.set(i + n/2, left.get(i));%0A        %7D%0A%0A        return total
 ;%0A  

change of function concatenateBitStrings