Combination generator ported from Java