Implements combinatorics