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 2bbad09 commit 1bb4e51
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "491a32c3af53ada53c6e874e2a142c02f10d9d27fc923e31fb6e1fee3b5726b8",
"originHash" : "bade67b167d95524e1f02f49472bc9d2d25b3f835dd08ea689d4c41b80b20d16",
"pins" : [
{
"identity" : "aoctools",
"kind" : "remoteSourceControl",
"location" : "https://github.com/gereons/AoCTools",
"state" : {
"revision" : "d7971984089e4724cee928895176db6e81939491",
"version" : "0.1.0"
"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 @@ -6,7 +6,7 @@ let package = Package(
name: "AdventOfCode",
platforms: [ .macOS(.v15) ],
dependencies: [
.package(url: "https://github.com/gereons/AoCTools", from: "0.1.0"),
.package(url: "https://github.com/gereons/AoCTools", from: "0.1.6"),
// .package(path: "../AoCTools"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Sources/AoC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation

@main
@MainActor
struct AdventOfCode {
enum AdventOfCode {
// assign to eg `.day(1)`, leave as nil to run the puzzle for the current calendar day
static var defaultDay: Day? // = .day(1)

Expand Down
6 changes: 3 additions & 3 deletions Sources/Day04/Day04.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ private struct Card {
init(_ string: String) {
// Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
let parts = string.components(separatedBy: ":")
self.id = parts[0].allInts().first!
self.id = parts[0].integers().first!
let nums = parts[1].components(separatedBy: "|")
let winners = Set(nums[0].allInts())
let numbers = Set(nums[1].allInts())
let winners = Set(nums[0].integers())
let numbers = Set(nums[1].integers())
matches = numbers.intersection(winners).count
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Day05/Day05.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private struct Almanac {
let maps: [Map]

init(_ lines: [String]) {
seeds = lines[0].allInts()
seeds = lines[0].integers()
let chunks = Array(lines.dropFirst(2)).grouped { $0.isEmpty }

maps = chunks.map { Map($0) }
Expand Down Expand Up @@ -50,7 +50,7 @@ private struct Range {
}

init(_ string: String) {
let ints = string.allInts()
let ints = string.integers()
self.init(from: ints[1], to: ints[1] + ints[2] - 1, adjustment: ints[0] - ints[1])
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Day06/Day06.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ final class Day06: AOCDay {
init(input: String) {
let lines = input.lines

let times = lines[0].allInts()
let distances = lines[1].allInts()
let times = lines[0].integers()
let distances = lines[1].integers()

races = zip(times, distances).map { Race(time: $0, distance: $1) }

let totalTime = lines[0].replacingOccurrences(of: " ", with: "").allInts()[0]
let totalDistance = lines[1].replacingOccurrences(of: " ", with: "").allInts()[0]
let totalTime = lines[0].replacingOccurrences(of: " ", with: "").integers()[0]
let totalDistance = lines[1].replacingOccurrences(of: " ", with: "").integers()[0]
part2Race = Race(time: totalTime, distance: totalDistance)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day09/Day09.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class Day09: AOCDay {
let sequences: [[Int]]

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

func part1() -> Int {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Day12/Day12.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private struct Row: Hashable {
init(_ string: String) {
let parts = string.components(separatedBy: " ")
record = parts[0]
groups = parts[1].allInts()
groups = parts[1].integers()
}

init<S: StringProtocol>(record: S, groups: [Int]) {
Expand Down Expand Up @@ -100,7 +100,7 @@ final class Day12: AOCDay {
return row.groups.count == 1 ? 1 : 0
}

if "?.".contains(row.record.charAt(group)) {
if "?.".contains(row.record[group]) {
return arrangements(Row(record: row.record.dropFirst(group + 1),
groups: Array(row.groups.dropFirst())))
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Day17/Day17.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private struct City: Pathfinding {
self.chainRange = chainRange
}

func neighbors(for state: State) -> [State] {
func neighbors(of state: State) -> [State] {
var result = [State]()
for dir in Direction.orthogonal {
if let direction = state.direction {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Day19/Day19.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private struct Rule {
let value: Int
let result: String

enum Comp: String {
enum Comp: Character {
case lt = "<"
case gt = ">"
}
Expand All @@ -53,8 +53,8 @@ private struct Rule {
value = 0
result = parts[0]
} else {
property = parts[0].charAt(0)
comparison = Comp(rawValue: parts[0].charAt(1))!
property = String(parts[0][0])
comparison = Comp(rawValue: parts[0][1])!
value = Int(parts[0].dropFirst(2))!
result = parts[1]
}
Expand Down Expand Up @@ -87,7 +87,7 @@ private struct Part {

// {x=787,m=2655,a=1222,s=2876}
init(_ string: String) {
let ints = string.allInts()
let ints = string.integers()
x = ints[0]
m = ints[1]
a = ints[2]
Expand Down
4 changes: 2 additions & 2 deletions Sources/Day22/Day22.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ private struct Brick {

init(_ string: String) {
let parts = string.components(separatedBy: "~")
let s = parts[0].allInts()
let e = parts[1].allInts()
let s = parts[0].integers()
let e = parts[1].integers()
self.init(start: Point3(s[0], s[1], s[2]),
end: Point3(e[0], e[1], e[2]))
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Day24/Day24.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ private struct Stone {
// 19, 13, 30 @ -2, 1, -2
init(_ string: String) {
let parts = string.components(separatedBy: "@")
let pos = parts[0].allInts().map { Double($0) }
let vel = parts[1].allInts().map { Double($0) }
let pos = parts[0].integers().map { Double($0) }
let vel = parts[1].integers().map { Double($0) }
p = (pos[0], pos[1], pos[2])
v = (vel[0], vel[1], vel[2])
}
Expand Down

0 comments on commit 1bb4e51

Please sign in to comment.