Skip to content

Instantly share code, notes, and snippets.

@wudaown
Created February 2, 2013 13:41
Show Gist options
  • Save wudaown/4697430 to your computer and use it in GitHub Desktop.
Save wudaown/4697430 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python3.2
# _*_ coding:utf8 _*_
def durian():
"""docstring for durian"""
infile=open("test1","r").read()
list=infile.split(",")
# print(list)
dlist=[]
for i in range(len(list)):
# print(i)
dlist.append(list[i][0])
dlist.append(list[i][2])
# print(dlist)
seen = set()
seen_add = seen.add
dlist=[x for x in dlist if x not in seen and not seen_add(x)]
dlist.sort()
rep = []
for i in range(len(dlist)):
rep.append(0)
print(list)
print(rep)
for i in range(len(list)):
if list[i][1] == ">":
print("greater")
#if list[i][0] in dlist:
# rep[i] = i + 1
#if list[i][0] == dlist[0]:
# rep[i] = i+1
#else:
if list[i][0] in dlist and list[i][2] in dlist:
rep[dlist.index(list[i][0])] = rep[dlist.index(list[i][0])] + 1
rep[dlist.index(list[i][2])] = rep[dlist.index(list[i][2])] - 1
else:
print("smaller")
if list[i][0] in dlist and list[i][2] in dlist:
rep[dlist.index(list[i][0])] = rep[dlist.index(list[i][0])] - 1
rep[dlist.index(list[i][2])] = rep[dlist.index(list[i][2])] + 1
print(rep)
return dlist
print(durian())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment