Created
March 9, 2021 10:56
-
-
Save aloisdg/97615eba3c62cb09697ae7890a0cfdc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def transpose(groups): | |
# return list(map(list, zip(*groups))) | |
result = [] | |
longest = max([len(x) for x in groups]) | |
for index in range(longest): | |
sub = [] | |
for group in groups: | |
if index < len(group): | |
sub.append(group[index]) | |
result.append(sub) | |
return result | |
def shuffleEach(groups): | |
result = [] | |
for group in groups: | |
result.append(random.sample(group, len(group))) | |
return random.sample(result, len(result)) | |
groups = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15]] | |
print(transpose(shuffleEach(groups))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment