This commit is contained in:
2022-07-07 16:45:18 +02:00
parent 73ae6f90f2
commit 88563913ff
14 changed files with 181 additions and 14 deletions

View File

@@ -13,10 +13,10 @@ var horizontalPosition = 0
let fileContent = try! String(contentsOfFile: CommandLine.arguments[1])
for line in fileContent.trimmingCharacters(in: .newlines).components(separatedBy: .newlines) {
let parts = line.components(separatedBy: " ")
let direction = parts[0]
let number = Int(parts[1])!
switch direction {
case "forward":
horizontalPosition += number
@@ -37,10 +37,10 @@ var horizontalPositionB = 0
for line in fileContent.trimmingCharacters(in: .newlines).components(separatedBy: .newlines) {
let parts = line.components(separatedBy: .whitespaces)
let direction = parts[0]
let number = Int(parts[1])!
switch direction {
case "up":
aim -= number