Refactor some of our tool code.

This commit is contained in:
Anna Rose 2020-12-14 23:27:46 +00:00
parent 4cc37c6e39
commit 2614bb2def
16 changed files with 29 additions and 31 deletions

View File

@ -4,12 +4,12 @@ import (
"fmt"
"os"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func main() {
step := os.Args[1]
values := fileutils.InputParserIntMap(os.Args[2])
values := util.InputParserIntMap(os.Args[2])
switch step {
case "1":

View File

@ -7,7 +7,7 @@ import (
"strconv"
"strings"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func checkLine(line string, step string) int {
@ -50,7 +50,7 @@ func checkLine(line string, step string) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
total := 0
for _, line := range values {

View File

@ -4,7 +4,7 @@ import (
"fmt"
"os"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func countTrees(input []string, right, down int) int {
@ -26,7 +26,7 @@ func countTrees(input []string, right, down int) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
switch step {
case "1":

View File

@ -8,7 +8,6 @@ import (
"strconv"
"strings"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
@ -130,7 +129,7 @@ func makeInt(input string) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
values = util.SplitOnBlankLine(values)
fmt.Println("Valid Passports:", countValidPassports(values, step))

View File

@ -7,7 +7,7 @@ import (
"strconv"
"strings"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func calculateSeatNumber(input string) int {
@ -28,7 +28,7 @@ func calculateSeatNumber(input string) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
switch step {
case "1":

View File

@ -5,7 +5,6 @@ import (
"os"
"strings"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
@ -45,7 +44,7 @@ func countAnswerIntersection(input string) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
groups := util.SplitOnBlankLine(values)
total := 0

View File

@ -7,7 +7,7 @@ import (
"regexp"
"strconv"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
type Node struct {
@ -89,7 +89,7 @@ func countChildren(node *Node) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
nodeMap = make(map[string]*Node)

View File

@ -7,7 +7,7 @@ import (
"strconv"
"strings"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
type Instruction struct {
@ -59,7 +59,7 @@ func executeProgram(instructions []Instruction) (int, bool) {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
instructions := make([]Instruction, 0)

View File

@ -5,7 +5,7 @@ import (
"log"
"os"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
type SumTracker map[int][]Tuple
@ -85,7 +85,7 @@ func sumMinMax(values []int) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserInts(os.Args[2])
values := util.InputParserInts(os.Args[2])
var badValue int
sumMap := make(SumTracker)

View File

@ -5,7 +5,7 @@ import (
"log"
"os"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func getMax(values map[int]bool) int {
@ -88,7 +88,7 @@ func countPaths(node *Node, target int) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserIntMap(os.Args[2])
values := util.InputParserIntMap(os.Args[2])
diffMap := make(map[int]int)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"os"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func occupied1(board [][]byte, i, j int) int {
@ -95,7 +95,7 @@ func countOccupied(board [][]byte) int {
func main() {
step := os.Args[1]
board := fileutils.InputParserBytes(os.Args[2])
board := util.InputParserBytes(os.Args[2])
changed := true
for changed {

View File

@ -6,7 +6,7 @@ import (
"os"
"strconv"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func distance(x1, y1, x2, y2 int) int {
@ -133,7 +133,7 @@ func step2(values []string) (int, int) {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
x := 0
y := 0

View File

@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
//
@ -108,7 +108,7 @@ func findTimestampWithCRT(busList []int) *big.Int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
earliest, busList := parseInput(values)

View File

@ -7,7 +7,7 @@ import (
"regexp"
"strconv"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
type Instruction struct {
@ -140,7 +140,7 @@ func executeProgram2(program []Instruction) map[int64]int64 {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
var memory map[int64]int64
program := parseProgram(values, step)

View File

@ -1,4 +1,4 @@
package fileutils
package util
import (
"bufio"

View File

@ -4,11 +4,11 @@ import (
"fmt"
"os"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func main() {
// step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values := util.InputParserStrings(os.Args[2])
}