Skip to content

Commit

Permalink
make input non-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
gereons committed Dec 1, 2023
1 parent e34f276 commit b6c7bbe
Show file tree
Hide file tree
Showing 27 changed files with 32 additions and 31 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/gereons/AoCTools",
"state" : {
"revision" : "689dbf8aa5897c5ab520cae6a9e6a339b12dddfe",
"version" : "0.0.40"
"revision" : "ea420cd028878482b9e80e556d75abe7048e2d27",
"version" : "0.0.41"
}
}
],
Expand Down
7 changes: 4 additions & 3 deletions Sources/AoC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ struct AdventOfCode {
private static func run(_ day: Day) {
switch day {
case .all:
days.forEach { day in
day.init(input: nil).run()
for day in days {
day.init(input: day.input).run()
}
case .day(let day):
days[day-1].init(input: nil).run()
let day = days[day - 1]
day.init(input: day.input).run()
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Day01/Day01.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import AoCTools
final class Day01: AOCDay {
let lines: [String]

init(input: String?) {
lines = (input ?? Self.input).lines
init(input: String) {
lines = input.lines
}

func part1() -> Int {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Day02/Day02.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day02: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day03/Day03.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day03: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day04/Day04.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day04: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day05/Day05.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day05: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day06/Day06.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day06: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day07/Day07.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day07: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day08/Day08.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day08: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day09/Day09.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day09: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day10/Day10.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day10: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day11/Day11.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day11: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day12/Day12.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day12: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day13/Day13.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day13: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day14/Day14.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day14: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day15/Day15.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day15: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day16/Day16.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day16: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day17/Day17.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day17: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day18/Day18.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day18: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day19/Day19.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day19: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day20/Day20.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day20: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day21/Day21.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day21: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day22/Day22.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day22: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day23/Day23.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day23: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day24/Day24.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day24: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Day25/Day25.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AoCTools

final class Day25: AOCDay {

init(input: String?) {
init(input: String) {
// let input = input ?? Self.input
}

Expand Down

0 comments on commit b6c7bbe

Please sign in to comment.