Skip to content

Instantly share code, notes, and snippets.

@ChristinaLK
Created September 2, 2013 19:33
Show Gist options
  • Save ChristinaLK/6416519 to your computer and use it in GitHub Desktop.
Save ChristinaLK/6416519 to your computer and use it in GitHub Desktop.
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