Last active
February 7, 2020 04:09
-
-
Save graup/70b09323bfa7182fe693eecb8e749896 to your computer and use it in GitHub Desktop.
This file contains 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
def balanced_latin_squares(n): | |
l = [[((j//2+1 if j%2 else n-j//2) + i) % n + 1 for j in range(n)] for i in range(n)] | |
if n % 2: # Repeat reversed for odd n | |
l += [seq[::-1] for seq in l] | |
return l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment