Rotating every 3 bits of integer in C++ : <p>Note the following may have exactly the same solution if x is any positive integer, but for the exact problem at hand:</p>

<p>Choose an integer 0 &lt; n &lt; 11. Let x be an integer whose binary representation is given by pasting together up to n of the 3-bit strings: 001, 010, 100, 111 in some order (this is "Numbers with digits 1,2,4,7 when written in base 8", see e.g. <a href="http://oeis.org/A308496" rel="nofollow noreferrer">http://oeis.org/A308496</a> ). Let y be the integer formed by rotating each 3-bit substring of x by 1 to the left. E.g. if 
(x)_2 = 001_010_111_100 then (y)_2 = 010_100_111_001 </p>

<p>Problem: Let x_1, x_2, ... x_m be a sequence of such x for a given n, find the corresponding y_1, y_2, ... y_m. </p>

<p>If m is less than, say, a few thousand, then speed is not really an issue. One could e.g. break "001_010_111_100" down into an array [001, 010, 111, 100] and perform bit rotation for each element of the array.  </p>

<p>However, once m becomes quite large (e.g. > 10^6), this task needs to be optimized as much as possible. Any suggestions (to a C++ beginner)?</p>
