finished alternateSplit and reverseInKGroups