Created
September 2, 2013 19:33
-
-
Save ChristinaLK/6416519 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
import sys | |
def lineTest(tabl,ind,num): | |
switch = True | |
for i in tabl[ind]: | |
if i > num: | |
switch = False | |
break | |
return switch | |
def RSKappend(tabl, num, ind): | |
tabl[ind].append(num) | |
return False | |
def RSKreplace(tabl, num, ind): | |
retVar = 0 | |
for i in tabl[ind]: | |
if i > num: | |
tabl[ind][tabl[ind].index(i)] = num | |
retVar = i | |
break | |
return retVar | |
perm = sys.argv[1:] | |
tableaux = [[]] | |
for j in perm: | |
bln = True | |
index = 0 | |
while bln: | |
if len(tableaux) <= index: | |
tableaux.append([]) | |
if lineTest(tableaux, index, j): | |
bln = RSKappend(tableaux, j, index) | |
else: | |
j = RSKreplace(tableaux, j, index) | |
index += 1 | |
print tableaux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment