from time import clock import sys def bintodec(n): global total j = 0 count=0 count1=0 for i in n: j = j * 2 + int(i) count=count+1 count1=count total+=sys.getsizeof(j)+sys.getsizeof(count)+sys.getsizeof(count1)+sys.getsizeof(n) return j,count,count1 f=open("c:\inputs\in5_7.txt","r+") f1=open("out_7_sec5_7.txt","w") total=0 temp=[] k1=[] a,b=f.readline().split(",") start=clock() i1,add1,mul1=bintodec(str(int(a))) i2,add2,mul2=bintodec(str(int(b))) m=clock()-start for l in range(int(i1),int(i2)+1): if(l==int(i2)): f1.write(str(l)+"\n") else: f1.write(str(l)+",") total+=sys.getsizeof(f)+sys.getsizeof(f1)+sys.getsizeof(temp)+sys.getsizeof(k1)+sys.getsizeof(a)+sys.getsizeof(b) total+=sys.getsizeof(start)+sys.getsizeof(i1)+sys.getsizeof(add1)+sys.getsizeof(mul1) total+=sys.getsizeof(i2)+sys.getsizeof(add2)+sys.getsizeof(mul2)+sys.getsizeof(m) f1.write("Time taken is "+str(m)+"\n") f1.write("Number of addition is "+str(add1+add2+2)+"\n") f1.write("Number of multiplication is "+str(mul1+mul2)+"\n") f1.write("Memory required is "+str(total)+" bytes") f.close() f1.close()