Rename shared packages by day instead of vaguely by purpose.
This commit is contained in:
parent
42cb05ba7f
commit
31f60eca0e
|
@ -4,15 +4,15 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"internal/calibration"
|
||||
"internal/day01"
|
||||
)
|
||||
|
||||
// Provide a filename as input, get the result on stdout
|
||||
func main() {
|
||||
x := 0
|
||||
seen := calibration.Set{} // we don't use this until day01-2, just added here for backwards compatibility
|
||||
seen := day01.Set{} // we don't use this until day01-2, just added here for backwards compatibility
|
||||
|
||||
x, _ = calibration.ScanFrequencies(os.Args[1], &seen, x)
|
||||
x, _ = day01.ScanFrequencies(os.Args[1], &seen, x)
|
||||
|
||||
fmt.Println("Frequency list scanned, calibration complete: ", x)
|
||||
}
|
||||
|
|
|
@ -4,17 +4,17 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"internal/calibration"
|
||||
"internal/day01"
|
||||
)
|
||||
|
||||
// Provide a filename as input, get the result on stdout
|
||||
func main() {
|
||||
x := 0
|
||||
found := false
|
||||
seen := calibration.Set{0: struct{}{}}
|
||||
seen := day01.Set{0: struct{}{}}
|
||||
|
||||
for {
|
||||
x, found = calibration.ScanFrequencies(os.Args[1], &seen, x)
|
||||
x, found = day01.ScanFrequencies(os.Args[1], &seen, x)
|
||||
if found {
|
||||
break
|
||||
}
|
||||
|
|
|
@ -3,14 +3,14 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/fabric"
|
||||
"internal/day03"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInput()
|
||||
claims, maxX, maxY := fabric.ParseClaims(data)
|
||||
grid := fabric.PopulateGrid(claims, maxX, maxY)
|
||||
claims, maxX, maxY := day03.ParseClaims(data)
|
||||
grid := day03.PopulateGrid(claims, maxX, maxY)
|
||||
|
||||
count := 0
|
||||
for y := 0; y < len(grid); y++ {
|
||||
|
|
|
@ -3,14 +3,14 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/fabric"
|
||||
"internal/day03"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInput()
|
||||
claims, maxX, maxY := fabric.ParseClaims(data)
|
||||
fabric.PopulateGrid(claims, maxX, maxY) // ignoring return value because we only want the side effect here
|
||||
claims, maxX, maxY := day03.ParseClaims(data)
|
||||
day03.PopulateGrid(claims, maxX, maxY) // ignoring return value because we only want the side effect here
|
||||
|
||||
id := -1
|
||||
count := 0
|
||||
|
|
|
@ -3,14 +3,14 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/guards"
|
||||
"internal/day04"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInput()
|
||||
shifts := guards.ParseInput(data)
|
||||
guards := guards.BuildGuards(shifts)
|
||||
shifts := day04.ParseInput(data)
|
||||
guards := day04.BuildGuards(shifts)
|
||||
|
||||
sleepiest, sleepiestMinute := FindSleepiestData(guards)
|
||||
|
||||
|
@ -19,8 +19,8 @@ func main() {
|
|||
fmt.Printf("Result: %d\n", sleepiest.ID*sleepiestMinute)
|
||||
}
|
||||
|
||||
func FindSleepiestData(data map[int]*guards.Guard) (*guards.Guard, int) {
|
||||
var sleepiest *guards.Guard
|
||||
func FindSleepiestData(data map[int]*day04.Guard) (*day04.Guard, int) {
|
||||
var sleepiest *day04.Guard
|
||||
for _, guard := range data {
|
||||
if sleepiest == nil {
|
||||
sleepiest = guard
|
||||
|
|
|
@ -3,14 +3,14 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/guards"
|
||||
"internal/day04"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInput()
|
||||
shifts := guards.ParseInput(data)
|
||||
guards := guards.BuildGuards(shifts)
|
||||
shifts := day04.ParseInput(data)
|
||||
guards := day04.BuildGuards(shifts)
|
||||
|
||||
sleepiest, sleepiestMinute := FindSleepiestData(guards)
|
||||
|
||||
|
@ -19,8 +19,8 @@ func main() {
|
|||
fmt.Printf("Result: %d\n", sleepiest.ID*sleepiestMinute)
|
||||
}
|
||||
|
||||
func FindSleepiestData(data map[int]*guards.Guard) (*guards.Guard, int) {
|
||||
var sleepiest *guards.Guard
|
||||
func FindSleepiestData(data map[int]*day04.Guard) (*day04.Guard, int) {
|
||||
var sleepiest *day04.Guard
|
||||
var minute, value int
|
||||
|
||||
for _, guard := range data {
|
||||
|
|
|
@ -3,12 +3,12 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/polymer"
|
||||
"internal/day05"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInputBytes()
|
||||
result := polymer.ApplyReactions(data)
|
||||
result := day05.ApplyReactions(data)
|
||||
fmt.Println(len(result))
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/polymer"
|
||||
"internal/day05"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
|
@ -12,8 +12,8 @@ func main() {
|
|||
result := [26][]byte{}
|
||||
|
||||
for i := 0; i < 26; i++ {
|
||||
result[i] = polymer.StripElement(data, rune('a'+i))
|
||||
result[i] = polymer.ApplyReactions(result[i])
|
||||
result[i] = day05.StripElement(data, rune('a'+i))
|
||||
result[i] = day05.ApplyReactions(result[i])
|
||||
}
|
||||
|
||||
shortest := len(result[0])
|
||||
|
|
|
@ -3,15 +3,15 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/coords"
|
||||
"internal/day06"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInput()
|
||||
points := coords.ParsePoints(data)
|
||||
points := day06.ParsePoints(data)
|
||||
|
||||
coords.ComputeRectilinearAreas(points)
|
||||
day06.ComputeRectilinearAreas(points)
|
||||
|
||||
biggest := points[0]
|
||||
for _, point := range points {
|
||||
|
|
|
@ -3,14 +3,14 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/coords"
|
||||
"internal/day06"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
data := util.ReadInput()
|
||||
points := coords.ParsePoints(data)
|
||||
points := day06.ParsePoints(data)
|
||||
|
||||
area := coords.ComputeNearnessRegion(points, 10000)
|
||||
area := day06.ComputeNearnessRegion(points, 10000)
|
||||
fmt.Println(area)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"internal/tree"
|
||||
"internal/day07"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
|
@ -12,10 +12,10 @@ func main() {
|
|||
data := util.ReadInput()
|
||||
|
||||
// Build a tree of dependencies.
|
||||
root := tree.BuildDependencyTree(data)
|
||||
root := day07.BuildDependencyTree(data)
|
||||
|
||||
// Walk the tree and determine the correct ordering.
|
||||
order := tree.FindOrder(root)
|
||||
order := day07.FindOrder(root)
|
||||
|
||||
output := strings.Builder{}
|
||||
for _, node := range order {
|
||||
|
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"internal/tree"
|
||||
"internal/day07"
|
||||
"internal/util"
|
||||
)
|
||||
|
||||
|
@ -11,9 +11,9 @@ func main() {
|
|||
data := util.ReadInput()
|
||||
|
||||
// Build a tree of dependencies.
|
||||
root := tree.BuildDependencyTree(data)
|
||||
root := day07.BuildDependencyTree(data)
|
||||
|
||||
// Build
|
||||
time := tree.SimulateConstruction(root)
|
||||
time := day07.SimulateConstruction(root)
|
||||
fmt.Println(time)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package calibration
|
||||
package day01
|
||||
|
||||
import (
|
||||
"bufio"
|
|
@ -1,5 +1,4 @@
|
|||
// Used by both parts of day 03
|
||||
package fabric
|
||||
package day03
|
||||
|
||||
import (
|
||||
"strconv"
|
|
@ -1,4 +1,4 @@
|
|||
package guards
|
||||
package day04
|
||||
|
||||
import (
|
||||
"sort"
|
|
@ -1,5 +1,5 @@
|
|||
// Functions for operating on polymers from day 5.
|
||||
package polymer
|
||||
package day05
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -1,4 +1,4 @@
|
|||
package coords
|
||||
package day06
|
||||
|
||||
import (
|
||||
"strconv"
|
|
@ -1,7 +1,7 @@
|
|||
// BreadthFirstOrder and its companion functions ended up not giving the
|
||||
// right solution, but I'm leaving them here as a useful generic tree
|
||||
// algorithm.
|
||||
package tree
|
||||
package day07
|
||||
|
||||
func BreadthFirstOrder(root *Node) []*Node {
|
||||
seen := make(map[rune]bool)
|
|
@ -1,4 +1,4 @@
|
|||
package tree
|
||||
package day07
|
||||
|
||||
func SimulateConstruction(root *Node) int {
|
||||
working := make(map[rune]*Node)
|
|
@ -1,4 +1,4 @@
|
|||
package tree
|
||||
package day07
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package tree
|
||||
package day07
|
||||
|
||||
// FindOrder determines the correct order according to these rules:
|
||||
// 1. A node cannot come before all of its parents have been included.
|
|
@ -1,4 +1,4 @@
|
|||
package tree
|
||||
package day07
|
||||
|
||||
import (
|
||||
"regexp"
|
Loading…
Reference in New Issue
Block a user