Problem

Source:

Tags: floor function, combinatorics proposed, combinatorics



Let $k$ and $n$ be positive integers, with $k \geq 2$. In a straight line there are $kn$ stones of $k$ colours, such that there are $n$ stones of each colour. A step consists of exchanging the position of two adjacent stones. Find the smallest positive integer $m$ such that it is always possible to achieve, with at most $m$ steps, that the $n$ stones are together, if: a) $n$ is even. b) $n$ is odd and $k=3$