#combinatorics problem solution