Guest User

for Bad Code Coding Challenge #58

a guest
Mar 22nd, 2021
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.96 KB | None | 0 0
  1. import time
  2.  
  3. def isTheInputFileOrderedCorrectlyThenReturnTrue(nameOfTheFile):
  4.     temp = True
  5.     asdf=0
  6.     while True:
  7.         try:
  8.             getCharOfFileName(nameOfTheFile, 0, asdf)
  9.             asdf = asdf + 1
  10.         except:
  11.             break
  12.  
  13.     try:
  14.         for indexl in range(asdf):
  15.             try:
  16.                 for index1 in range(asdf):
  17.                     isInOrder=False
  18.                     asdfg = False
  19.                     try:
  20.                         for ind1 in range(asdf):
  21.                             try:
  22.                                 char1 = getCharOfFileName(nameOfTheFile,indexl,ind1)
  23.                                 charl = getCharOfFileName(nameOfTheFile,index1,ind1)
  24.                                 if abs(index1-indexl)>0:
  25.                                     asdfg = True
  26.                                 if char1 > charl:
  27.                                     if not (index1 > indexl):
  28.                                         isInOrder = True
  29.                                 if char1 < charl:
  30.                                     if indexl>index1:
  31.                                         if not isInOrder:
  32.                                             temp=False
  33.                             except:
  34.                                 continue
  35.                     except:
  36.                         continue
  37.                     if isInOrder is not True and not indexl < index1 and asdfg:
  38.                         temp = isInOrder
  39.             except:
  40.                 continue
  41.     except:
  42.         asdf=asdf
  43.     if temp:
  44.         return True
  45.     else:
  46.         return not True
  47.  
  48.  
  49. def getCharOfFileName(file_name,line,numberofcharacterinline):
  50.     with open(file_name) as fi1e_name:
  51.         while line>0:
  52.             c=''
  53.             while c != '\n':
  54.                 c = fi1e_name.read(1)
  55.                 if not c:
  56.                     raise ValueError('End')
  57.             line = subtract1(line)
  58.         while numberofcharacterinline+1:
  59.             c = fi1e_name.read(1)
  60.             numberofcharacterinline=subtract1(numberofcharacterinline)
  61.             if not c:
  62.                 raise ValueError('End')
  63.     return c
  64.  
  65. def subtract1(a):
  66.     b=-10
  67.     while b<a-1:
  68.         b=b+1
  69.     return b
  70. start_time = time.time()
  71. print("0.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('0.txt')))
  72. print("Execution was {}s".format(time.time()-start_time))
  73. print("1.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('1.txt')))
  74. print("Execution was {}s".format(time.time()-start_time))
  75. print("2.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('2.txt')))
  76. print("Execution was {}s".format(time.time()-start_time))
  77. print("3.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('3.txt')))
  78. print("Execution was {}s".format(time.time()-start_time))
  79. print("4.txt is Ordered:"+ str(isTheInputFileOrderedCorrectlyThenReturnTrue('4.txt')))
  80. print("Execution was {}s".format(time.time()-start_time))
Advertisement
Add Comment
Please, Sign In to add comment