"order" function completed, tested and is working.

This commit is contained in:
JellieJayde
2024-04-24 14:33:21 -04:00
parent 1ade3555f0
commit 129429b48b

View File

@@ -24,42 +24,59 @@ from os import path
execDir = path.dirname(__file__) execDir = path.dirname(__file__)
dataLanguage = []
dataEncoded = []
def parse(dataReference, dataEncoded): def parse(dataReference, dataEncoded):
return order(dataReference), order(dataEncoded) return order(dataReference), order(dataEncoded)
def order(text:str): def order(file):
for character in text:
if character.isalpha(): dataLanguage = []
amount = []
index = 0
pass with open(execDir + file, "r") as f:
while True:
fileChar = f.read(1).strip()
with open(execDir + "\\dataReference.txt", "r") as f: if fileChar.isalpha():
while True: if fileChar.lower() not in dataLanguage:
dataLanguageChar = f.read(1).strip() dataLanguage.append(fileChar.lower())
amount.append(1)
if dataLanguageChar.isalpha(): else:
if dataLanguageChar.lower() not in dataLanguage: index = 0
dataLanguage.append(dataLanguageChar.lower()) while True:
if dataLanguage[index] == fileChar.lower():
amount[index] = amount[index] + 1
break
if dataLanguageChar == "~": else:
print (dataLanguage) index = index + 1
break
with open(execDir + "\\dataEncoded19.ENC", "r") as f: if fileChar == "~":
while True: index = 0
dataEncodedChar = f.read(1).strip() Finished = False
if dataEncodedChar.isalpha(): while not Finished:
if dataEncodedChar.lower() not in dataEncoded: Finished = True
dataEncoded.append(dataEncodedChar.lower())
if dataEncodedChar == "~": for index in range(0, len(amount) - 1):
print (dataEncoded) temp = amount[index]
break tempLetter = dataLanguage[index]
parse(dataLanguageChar, dataEncodedChar) if temp < amount[index + 1]:
amount[index] = amount[index + 1]
amount[index + 1] = temp
dataLanguage[index] = dataLanguage[index + 1]
dataLanguage[index + 1] = tempLetter
Finished = False
if index == len(amount):
index = 0
return dataLanguage, amount
print (order("\\dataReference.txt"), "\n")
print (order("\\dataEncoded19.ENC"), "\n")