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