first working version. Removed overloaded version of the getPermutations (int[][]), because it never needs to be used.