38 lines
806 B
Python
38 lines
806 B
Python
def findBankMax(bank: str):
|
|
maxChar = max(bank[0:-11])
|
|
frontLoc = bank.find(maxChar)
|
|
onList = bank[frontLoc]
|
|
while len(onList) < 11 :
|
|
maxChar = max(bank[frontLoc + 1:len(onList) - 11])
|
|
maxLoc = bank[frontLoc + 1:].find(maxChar)
|
|
onList += bank[frontLoc + 1 + maxLoc]
|
|
frontLoc += maxLoc + 1
|
|
onList += max(bank[frontLoc + 1:])
|
|
return int(onList)
|
|
|
|
testBanks = [
|
|
"987654321111111",
|
|
"811111111111119",
|
|
"234234234234278",
|
|
"818181911112111"
|
|
]
|
|
|
|
|
|
def readFile() :
|
|
ary = []
|
|
with open("files/Problem3.txt", "r") as file :
|
|
for line in file :
|
|
ary.append(line.replace("\n", ""))
|
|
return ary
|
|
|
|
|
|
#inputBanks = testBanks
|
|
inputBanks = readFile()
|
|
results = []
|
|
for bank in inputBanks :
|
|
bankMax = findBankMax(bank)
|
|
results.append(bankMax)
|
|
print(f"Results = {sum(results)}")
|
|
|
|
#Results = 170147128753455
|