Ten hats were hung on pegs as shown in the illustration—five silk hats and five felt "bowlers," alternately silk and felt. 
The two pegs at the end of the row were empty.

Remove two contiguous hats to the vacant pegs, then two other adjoining hats to the pegs now unoccupied, and so on until five pairs have been moved and the hats again hang in an unbroken row, but with all the silk ones together and all the felt hats together.

Remember, the two hats removed must always be contiguous ones, and you must take one in each hand and place them on their new pegs without reversing their relative position. 
You are not allowed to cross your hands, nor to hang up one at a time.

Try it with counters of two colours or with coins, and remember that the two empty pegs must be left at one end of the row.

See answer

Math Genius