6. On the parade ground, 2018 soldiers are lined up in one row. The commander can order either all soldiers standing in even positions or all soldiers standing in odd positions to leave the formation. After this order, the remaining soldiers close up into one row. In how many ways can the commander issue a series of 8 orders so that exactly 7 soldiers remain in the formation?
Answer: 30.

Let's add 30 imaginary people to the end of the line. We will number all the people in the line from 0 to 2047. We will write all these numbers in binary using 11 digits. This will result in sequences from 00000000000 to 11111111111. The imaginary soldiers correspond to numbers from 11111100010 to 11111111111 (from 2018 to 2047 in binary notation).

Notice that soldiers in even positions have 1 as the last digit in their binary representation, while soldiers in odd positions have 0. This means that after the order is executed, only soldiers with a fixed last digit remain in the line. After the next order, only soldiers with a fixed second-to-last digit remain, and so on.

After a series of 8 orders, the soldiers remaining in the line will have binary numbers of the form $\overline{x x a b c d e f g h}$, where the symbols $x$ represent digits that can take any value; $a, b, c, d, e, f, g, h$ are the digits fixed in the first eight orders. Clearly, soldiers with $\overline{x x x}=000,001,010,011,100,101,110$ were indeed present in the initial line, as the minimum number of an imaginary soldier starts with 111. We are interested in situations where the soldier with the number $\overline{111 a b c d e f g h}$ is imaginary (otherwise, 8 people remain). This happens exactly in 30 cases: from 11111100010 to 11111111111. In total, there are 30 possible groups of 7 people.