Cleaned up

This commit is contained in:
Max Nuding 2021-12-10 07:40:47 +01:00
parent d751bc64f8
commit 984ae73600
Signed by: phlaym
GPG Key ID: A06651BAB6777237

View File

@ -9,6 +9,7 @@ import Foundation
import Runner import Runner
import Collections import Collections
struct Day10: Runnable { struct Day10: Runnable {
let inputPath: String let inputPath: String
@ -17,11 +18,10 @@ struct Day10: Runnable {
let lines = input let lines = input
.trimmingCharacters(in: .newlines) .trimmingCharacters(in: .newlines)
.components(separatedBy: .newlines) .components(separatedBy: .newlines)
//.map { line in line.map { $0.wholeNumberValue! } }
var s = Deque<String.Element>() var s = Deque<String.Element>()
var illegalCharacters = [String.Element]() var illegalCharacters = [String.Element]()
var autocompleteScores = [Int]() var autocompleteScores = [Int]()
for (lineNumber, line) in lines.enumerated() { for line in lines {
s = Deque<String.Element>() s = Deque<String.Element>()
var isIllegalLine = false var isIllegalLine = false
for char in line { for char in line {
@ -55,8 +55,6 @@ struct Day10: Runnable {
print(illegalCharacters.map{$0.score!}.reduce(0,+)) print(illegalCharacters.map{$0.score!}.reduce(0,+))
print(autocompleteScores.sorted()[autocompleteScores.count / 2]) print(autocompleteScores.sorted()[autocompleteScores.count / 2])
} }
} }
extension String.Element { extension String.Element {