From 31f60eca0e42f57d365eb193aa32272d7e2ce863 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Mon, 10 Dec 2018 01:06:47 -0500 Subject: [PATCH] Rename shared packages by day instead of vaguely by purpose. --- 2018/day01-1.go | 6 +++--- 2018/day01-2.go | 6 +++--- 2018/day03-1.go | 6 +++--- 2018/day03-2.go | 6 +++--- 2018/day04-1.go | 10 +++++----- 2018/day04-2.go | 10 +++++----- 2018/day05-1.go | 4 ++-- 2018/day05-2.go | 6 +++--- 2018/day06-1.go | 6 +++--- 2018/day06-2.go | 6 +++--- 2018/day07-1.go | 6 +++--- 2018/day07-2.go | 6 +++--- 2018/internal/{calibration => day01}/calibration.go | 2 +- 2018/internal/{fabric => day03}/fabric_claims.go | 3 +-- 2018/internal/{guards => day04}/guards.go | 2 +- 2018/internal/{polymer => day05}/polymer.go | 2 +- 2018/internal/{coords => day06}/coords.go | 2 +- 2018/internal/{tree => day07}/breadthfirst.go | 2 +- 2018/internal/{tree => day07}/construction.go | 2 +- 2018/internal/{tree => day07}/debug.go | 2 +- 2018/internal/{tree => day07}/findorder.go | 2 +- 2018/internal/{tree => day07}/tree.go | 2 +- 22 files changed, 49 insertions(+), 50 deletions(-) rename 2018/internal/{calibration => day01}/calibration.go (97%) rename 2018/internal/{fabric => day03}/fabric_claims.go (97%) rename 2018/internal/{guards => day04}/guards.go (99%) rename 2018/internal/{polymer => day05}/polymer.go (98%) rename 2018/internal/{coords => day06}/coords.go (99%) rename 2018/internal/{tree => day07}/breadthfirst.go (98%) rename 2018/internal/{tree => day07}/construction.go (98%) rename 2018/internal/{tree => day07}/debug.go (97%) rename 2018/internal/{tree => day07}/findorder.go (98%) rename 2018/internal/{tree => day07}/tree.go (99%) diff --git a/2018/day01-1.go b/2018/day01-1.go index 6ab6bbc..142c8a1 100644 --- a/2018/day01-1.go +++ b/2018/day01-1.go @@ -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) } diff --git a/2018/day01-2.go b/2018/day01-2.go index 69fa62b..2cc96ca 100644 --- a/2018/day01-2.go +++ b/2018/day01-2.go @@ -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 } diff --git a/2018/day03-1.go b/2018/day03-1.go index bc853bf..09a92f5 100644 --- a/2018/day03-1.go +++ b/2018/day03-1.go @@ -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++ { diff --git a/2018/day03-2.go b/2018/day03-2.go index ea6858c..e59aa8e 100644 --- a/2018/day03-2.go +++ b/2018/day03-2.go @@ -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 diff --git a/2018/day04-1.go b/2018/day04-1.go index 59cd3b5..942cb94 100644 --- a/2018/day04-1.go +++ b/2018/day04-1.go @@ -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 diff --git a/2018/day04-2.go b/2018/day04-2.go index 6856867..a5e8720 100644 --- a/2018/day04-2.go +++ b/2018/day04-2.go @@ -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 { diff --git a/2018/day05-1.go b/2018/day05-1.go index 4b8ee5a..5e2f2d9 100644 --- a/2018/day05-1.go +++ b/2018/day05-1.go @@ -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)) } diff --git a/2018/day05-2.go b/2018/day05-2.go index d3774f6..7b4da5c 100644 --- a/2018/day05-2.go +++ b/2018/day05-2.go @@ -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]) diff --git a/2018/day06-1.go b/2018/day06-1.go index b10e70a..f00bcc5 100644 --- a/2018/day06-1.go +++ b/2018/day06-1.go @@ -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 { diff --git a/2018/day06-2.go b/2018/day06-2.go index 8ed1908..80ad013 100644 --- a/2018/day06-2.go +++ b/2018/day06-2.go @@ -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) } diff --git a/2018/day07-1.go b/2018/day07-1.go index 5e8cbdb..70ae09f 100644 --- a/2018/day07-1.go +++ b/2018/day07-1.go @@ -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 { diff --git a/2018/day07-2.go b/2018/day07-2.go index a282213..23a6667 100644 --- a/2018/day07-2.go +++ b/2018/day07-2.go @@ -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) } diff --git a/2018/internal/calibration/calibration.go b/2018/internal/day01/calibration.go similarity index 97% rename from 2018/internal/calibration/calibration.go rename to 2018/internal/day01/calibration.go index b11311b..523c7ef 100644 --- a/2018/internal/calibration/calibration.go +++ b/2018/internal/day01/calibration.go @@ -1,4 +1,4 @@ -package calibration +package day01 import ( "bufio" diff --git a/2018/internal/fabric/fabric_claims.go b/2018/internal/day03/fabric_claims.go similarity index 97% rename from 2018/internal/fabric/fabric_claims.go rename to 2018/internal/day03/fabric_claims.go index 0388c0e..3fee031 100644 --- a/2018/internal/fabric/fabric_claims.go +++ b/2018/internal/day03/fabric_claims.go @@ -1,5 +1,4 @@ -// Used by both parts of day 03 -package fabric +package day03 import ( "strconv" diff --git a/2018/internal/guards/guards.go b/2018/internal/day04/guards.go similarity index 99% rename from 2018/internal/guards/guards.go rename to 2018/internal/day04/guards.go index 19c456e..12bdbf1 100644 --- a/2018/internal/guards/guards.go +++ b/2018/internal/day04/guards.go @@ -1,4 +1,4 @@ -package guards +package day04 import ( "sort" diff --git a/2018/internal/polymer/polymer.go b/2018/internal/day05/polymer.go similarity index 98% rename from 2018/internal/polymer/polymer.go rename to 2018/internal/day05/polymer.go index 2d949e8..bfcc503 100644 --- a/2018/internal/polymer/polymer.go +++ b/2018/internal/day05/polymer.go @@ -1,5 +1,5 @@ // Functions for operating on polymers from day 5. -package polymer +package day05 import ( "bytes" diff --git a/2018/internal/coords/coords.go b/2018/internal/day06/coords.go similarity index 99% rename from 2018/internal/coords/coords.go rename to 2018/internal/day06/coords.go index 3fa8723..239b183 100644 --- a/2018/internal/coords/coords.go +++ b/2018/internal/day06/coords.go @@ -1,4 +1,4 @@ -package coords +package day06 import ( "strconv" diff --git a/2018/internal/tree/breadthfirst.go b/2018/internal/day07/breadthfirst.go similarity index 98% rename from 2018/internal/tree/breadthfirst.go rename to 2018/internal/day07/breadthfirst.go index 85da356..d3a39a4 100644 --- a/2018/internal/tree/breadthfirst.go +++ b/2018/internal/day07/breadthfirst.go @@ -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) diff --git a/2018/internal/tree/construction.go b/2018/internal/day07/construction.go similarity index 98% rename from 2018/internal/tree/construction.go rename to 2018/internal/day07/construction.go index e4355b1..d575219 100644 --- a/2018/internal/tree/construction.go +++ b/2018/internal/day07/construction.go @@ -1,4 +1,4 @@ -package tree +package day07 func SimulateConstruction(root *Node) int { working := make(map[rune]*Node) diff --git a/2018/internal/tree/debug.go b/2018/internal/day07/debug.go similarity index 97% rename from 2018/internal/tree/debug.go rename to 2018/internal/day07/debug.go index fea494e..69fcbac 100644 --- a/2018/internal/tree/debug.go +++ b/2018/internal/day07/debug.go @@ -1,4 +1,4 @@ -package tree +package day07 import ( "fmt" diff --git a/2018/internal/tree/findorder.go b/2018/internal/day07/findorder.go similarity index 98% rename from 2018/internal/tree/findorder.go rename to 2018/internal/day07/findorder.go index b68e5ec..b619e06 100644 --- a/2018/internal/tree/findorder.go +++ b/2018/internal/day07/findorder.go @@ -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. diff --git a/2018/internal/tree/tree.go b/2018/internal/day07/tree.go similarity index 99% rename from 2018/internal/tree/tree.go rename to 2018/internal/day07/tree.go index 65b8244..4c9dc16 100644 --- a/2018/internal/tree/tree.go +++ b/2018/internal/day07/tree.go @@ -1,4 +1,4 @@ -package tree +package day07 import ( "regexp"