coder
BAN USERmainpath="/usr/bin/mail"
relpath="../../../etc/xyz/../abc"
stack=mainpath.split("/")
val=relpath.split("/")
slen=len(stack)
leng=len(val)
for i in range(0,leng):
if val[i]=="..":
stack.pop()
else:
stack.append(val[i])
print stack
s=""
for x in stack:
s=s+x+"/"
print s
a=["low","med", "med","med","high","low","low","med","high","low"]
length=len(a)
low=0
high=length-1;
mid=low
while (low < high and mid< high):
if a[low] =="low":
low=low+1
if a[high]=="high":
high=high-1
if a[low]=="med" and mid==0:
mid=low
if a[mid]=="med":
mid=mid+1
if a[mid]=="high":
a[mid]=a[high]
a[high]="high"
high=high-1
if a[mid]=="low":
a[mid]=a[low]
a[low]="low"
low=low+1
print a
USE CASE statement
- coder January 14, 2015