Skip to content

Commit

Permalink
update tools
Browse files Browse the repository at this point in the history
  • Loading branch information
gereons committed Dec 28, 2024
1 parent 2335ac7 commit d82a0d1
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "5dd3524b7d5f73e2fcb51fd6a068ef044dbff1de9d2bc21ebb551fc79a4362ad",
"originHash" : "0143f3c2b660563bca033f76ffa9c8ca98618131218ccc5e53ccba3c5aed7255",
"pins" : [
{
"identity" : "aoctools",
"kind" : "remoteSourceControl",
"location" : "https://github.com/gereons/AoCTools",
"state" : {
"revision" : "4d9a9622e206981fc79c03473864f85c77b05a00",
"version" : "0.1.5"
"revision" : "d363eb88c324269a870d3fe233dd622c04ba3e60",
"version" : "0.1.6"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/lukepistrol/SwiftLintPlugin", from: "0.55.1"),
.package(url: "https://github.com/gereons/AoCTools", from: "0.1.3")
.package(url: "https://github.com/gereons/AoCTools", from: "0.1.6")
// .package(path: "../AoCTools")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Sources/Day01/Day01.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Day01: AOCDay {

init(input: String) {
let pairs = input.lines
.map { $0.allInts() }
.map { $0.integers() }

left = pairs.map { $0[0] }
right = pairs.map { $0[1] }
Expand Down
2 changes: 1 addition & 1 deletion Sources/Day02/Day02.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class Day02: AOCDay {
private let reports: [Report]

init(input: String) {
reports = input.lines.map { Report(data: $0.allInts()) }
reports = input.lines.map { Report(data: $0.integers()) }
}

func part1() -> Int {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Day05/Day05.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ final class Day05: AOCDay {
let groups = input.lines.grouped(by: \.isEmpty)

rules = groups[0]
.map { $0.allInts() }
.map { $0.integers() }
.map { Rule(page1: $0[0], page2: $0[1]) }
.makeSet()

updates = groups[1]
.map { $0.allInts() }
.map { $0.integers() }
}

func part1() -> Int {
Expand Down
3 changes: 1 addition & 2 deletions Sources/Day07/Day07.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
//

import AoCTools
import Foundation

final class Day07: AOCDay {
let title = "Bridge Repair"

let equations: [[Int]]
init(input: String) {
equations = input.lines.map { $0.allInts() }
equations = input.lines.map { $0.integers() }
}

func part1() -> Int {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Day11/Day11.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class Day11: AOCDay {
let stones: [Int]

init(input: String) {
stones = input.allInts()
stones = input.integers()
}

func part1() -> Int {
Expand Down
6 changes: 3 additions & 3 deletions Sources/Day13/Day13.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ final class Day13: AOCDay {
let groups = input.lines.grouped(by: \.isEmpty)

machines = groups.map {
let btnA = $0[0].allInts()
let btnB = $0[1].allInts()
let prize = $0[2].allInts()
let btnA = $0[0].integers()
let btnB = $0[1].integers()
let prize = $0[2].integers()
return Machine(
buttonA: Point(btnA[0], btnA[1]),
buttonB: Point(btnB[0], btnB[1]),
Expand Down
2 changes: 1 addition & 1 deletion Sources/Day14/Day14.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class Day14: AOCDay {

init(input: String, width: Int, height: Int) {
robots = input.lines
.map { $0.allInts() }
.map { $0.integers() }
.map { Robot(position: Point($0[0], $0[1]), velocity: Point($0[2], $0[3])) }
self.height = height
self.width = width
Expand Down
8 changes: 4 additions & 4 deletions Sources/Day17/Day17.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ final class Day17: AOCDay {

init(input: String) {
let lines = input.lines
let regA = lines[0].allInts()[0]
let regB = lines[1].allInts()[0]
let regC = lines[2].allInts()[0]
let program = lines[4].allInts()
let regA = lines[0].integers()[0]
let regB = lines[1].integers()[0]
let regC = lines[2].integers()[0]
let program = lines[4].integers()

cpu = ChronospatialComputer(program: program, initialRegisters: [regA, regB, regC])
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Day18/Day18.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class Day18: AOCDay {
var ram = [Point: Character]()

init(input: String) {
bytes = input.lines.map { $0.allInts() }.map { Point($0[0], $0[1]) }
bytes = input.lines.map { $0.integers() }.map { Point($0[0], $0[1]) }
}

func part1() -> Int {
Expand Down
14 changes: 1 addition & 13 deletions Sources/Day21/Day21.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,9 @@ final class Day21: AOCDay {
guard let nextChar = map[startPoint + dir] else { continue }
if nextChar != "X" && !visited.contains(nextChar) {
let nextSteps = generateSteps(map: map, start: nextChar, end: end, visited: visited + start)
results.append(contentsOf: nextSteps.map { dir.char + $0 })
results.append(contentsOf: nextSteps.map { dir.description + $0 })
}
}
return results
}
}

extension Direction {
var char: String {
switch self {
case .n: "^"
case .e: ">"
case .w: "<"
case .s: "v"
default: fatalError()
}
}
}

0 comments on commit d82a0d1

Please sign in to comment.