"""program to heplChef to determine how many holes are in the text. and determine What is the maximum number of pies the chef can cool on the racks?""" import time t0=time.clock() import sys a=[] fi=open("in20_8.txt",'r') w=open("out_18_20_8.txt",'w') count=0 for row in fi: a=row print a count=0 for i in a: if i=='A' or i=='P'or i=='R'or i=='O' or i=='D': count=count+1 if i=='B': count=count+1 print count w.write("no of holes="+repr(count)) a=[] b=[] c=[] d=[] e=[] p=[] wt=[] fi=open("in_sec201_8.txt",'r') count=1 for row in fi: list=row.split(" ") if count%3==1: for i in list: a.append(int(i)) if count%3==2: for i in list: b.append(int(i)) p.append(b) b=[] if count%3==0: for i in list: c.append(int(i)) wt.append(c) c=[] count+=1 print wt print p for i in range(2): count=0 for j in range(int(a[i])): m=max(p[i]) n=max(wt[i]) if n>=m: count=count+1 p[i].remove(m) wt[i].remove(n) else: p[i].remove(m) print count w.write('\n'+"the maximum no of pies can be placed on the racks in the"+repr(a[i])+"test case is="+repr(count)) t1=time.clock() t2=t1-t0 w.write('\n'+"time used by program="+repr(t2)) mem=sys.getsizeof(t0)+sys.getsizeof(t2)+sys.getsizeof(t2)+sys.getsizeof(j)+sys.getsizeof(i)+36 w.write('\n'+'memory used by the program='+repr(mem)) fi.close() w.close()