Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- def isTheInputFileOrderedCorrectlyThenReturnTrue(nameOfTheFile):
- temp = True
- asdf=0
- while True:
- try:
- getCharOfFileName(nameOfTheFile, 0, asdf)
- asdf = asdf + 1
- except:
- break
- try:
- for indexl in range(asdf):
- try:
- for index1 in range(asdf):
- isInOrder=False
- asdfg = False
- try:
- for ind1 in range(asdf):
- try:
- char1 = getCharOfFileName(nameOfTheFile,indexl,ind1)
- charl = getCharOfFileName(nameOfTheFile,index1,ind1)
- if abs(index1-indexl)>0:
- asdfg = True
- if char1 > charl:
- if not (index1 > indexl):
- isInOrder = True
- if char1 < charl:
- if indexl>index1:
- if not isInOrder:
- temp=False
- except:
- continue
- except:
- continue
- if isInOrder is not True and not indexl < index1 and asdfg:
- temp = isInOrder
- except:
- continue
- except:
- asdf=asdf
- if temp:
- return True
- else:
- return not True
- def getCharOfFileName(file_name,line,numberofcharacterinline):
- with open(file_name) as fi1e_name:
- while line>0:
- c=''
- while c != '\n':
- c = fi1e_name.read(1)
- if not c:
- raise ValueError('End')
- line = subtract1(line)
- while numberofcharacterinline+1:
- c = fi1e_name.read(1)
- numberofcharacterinline=subtract1(numberofcharacterinline)
- if not c:
- raise ValueError('End')
- return c
- def subtract1(a):
- b=-10
- while b<a-1:
- b=b+1
- return b
- start_time = time.time()
- print("0.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('0.txt')))
- print("Execution was {}s".format(time.time()-start_time))
- print("1.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('1.txt')))
- print("Execution was {}s".format(time.time()-start_time))
- print("2.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('2.txt')))
- print("Execution was {}s".format(time.time()-start_time))
- print("3.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('3.txt')))
- print("Execution was {}s".format(time.time()-start_time))
- print("4.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('4.txt')))
- print("Execution was {}s".format(time.time()-start_time))
Advertisement
Add Comment
Please, Sign In to add comment