"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: dataLanguage = []
amount = []
index = 0
if character.isalpha(): with open(execDir + file, "r") as f:
while True:
fileChar = f.read(1).strip()
pass if fileChar.isalpha():
if fileChar.lower() not in dataLanguage:
dataLanguage.append(fileChar.lower())
amount.append(1)
with open(execDir + "\\dataReference.txt", "r") as f: else:
while True: index = 0
dataLanguageChar = f.read(1).strip() while True:
if dataLanguage[index] == fileChar.lower():
amount[index] = amount[index] + 1
break
if dataLanguageChar.isalpha(): else:
if dataLanguageChar.lower() not in dataLanguage: index = index + 1
dataLanguage.append(dataLanguageChar.lower())
if dataLanguageChar == "~": if fileChar == "~":
print (dataLanguage) index = 0
break Finished = False
with open(execDir + "\\dataEncoded19.ENC", "r") as f: while not Finished:
while True: Finished = True
dataEncodedChar = f.read(1).strip()
if dataEncodedChar.isalpha(): for index in range(0, len(amount) - 1):
if dataEncodedChar.lower() not in dataEncoded: temp = amount[index]
dataEncoded.append(dataEncodedChar.lower()) tempLetter = dataLanguage[index]
if dataEncodedChar == "~": if temp < amount[index + 1]:
print (dataEncoded) amount[index] = amount[index + 1]
break amount[index + 1] = temp
parse(dataLanguageChar, dataEncodedChar) 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")