renamed module... for some reason

This commit is contained in:
alexchao26
2020-11-27 02:53:18 -05:00
parent b883a59052
commit 574bb4b9cc
58 changed files with 100 additions and 78 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+2 -2
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"sort" "sort"
"strconv" "strconv"
@@ -67,7 +67,7 @@ func main() {
} }
// print ID * time (minute) // print ID * time (minute)
fmt.Printf("Sleepiest guard is %v, at minute %v.\nAoC answer: %v\n", fmt.Printf("Sleepiest guard is %v, at minute %v.\ngithub.com/alexchao26/advent-of-code-go answer: %v\n",
IDOfSleepiestGuard, IDOfSleepiestGuard,
bestMinute, bestMinute,
IDOfSleepiestGuard*bestMinute, IDOfSleepiestGuard*bestMinute,
+2 -2
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"sort" "sort"
"strconv" "strconv"
@@ -59,7 +59,7 @@ func main() {
} }
// print ID * time (minute) // print ID * time (minute)
fmt.Printf("Guard %v is asleep the most at minute %v.\nAoC answer: %v\n", fmt.Printf("Guard %v is asleep the most at minute %v.\ngithub.com/alexchao26/advent-of-code-go answer: %v\n",
ID, ID,
bestMinute, bestMinute,
ID*bestMinute, ID*bestMinute,
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+2 -2
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
@@ -28,7 +28,7 @@ func main() {
// run step on the cloned slice // run step on the cloned slice
step(clone, 0) step(clone, 0)
// check if the zero address is equal to the AoC value // check if the zero address is equal to the github.com/alexchao26/advent-of-code-go value
if clone[0] == 19690720 { if clone[0] == 19690720 {
// print answers to console (manually add to advent of code) // print answers to console (manually add to advent of code)
fmt.Println("noun is", i, "verb is", j) fmt.Println("noun is", i, "verb is", j)
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+3 -3
View File
@@ -5,8 +5,8 @@ import (
"math" "math"
"strings" "strings"
"adventofcode/2019/day10/part2/trig" "github.com/alexchao26/advent-of-code-go/2019/day10/part2/trig"
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
) )
/* /*
@@ -98,7 +98,7 @@ func main() {
// print the last used asteroid // print the last used asteroid
fmt.Println("Last asteroid", lastAsteroid) fmt.Println("Last asteroid", lastAsteroid)
// print the AoC-formatted answer // print the github.com/alexchao26/advent-of-code-go-formatted answer
fmt.Println("Advent of code answer: ", lastAsteroid.y*100+lastAsteroid.x) fmt.Println("Advent of code answer: ", lastAsteroid.y*100+lastAsteroid.x)
} }
+1 -1
View File
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -9,7 +9,7 @@ Draw function generates a string to display in terminal
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -9,7 +9,7 @@ Draw function generates a string to display in terminal
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -10,7 +10,7 @@ NOTE: The "hold for an input" value was changed from -1 to -2 in the Intcode com
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -9,7 +9,7 @@ Robot struct houses an Intcode computer and its RecursiveMove method populates a
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"math" "math"
+1 -1
View File
@@ -12,7 +12,7 @@ Robot struct houses an Intcode computer and its RecursiveMove method populates a
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+2 -2
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
@@ -28,7 +28,7 @@ func main() {
digits = getNextOutputNumber(digits, patterns) digits = getNextOutputNumber(digits, patterns)
} }
// Transform into AoC output // Transform into github.com/alexchao26/advent-of-code-go output
var firstEightDigits int var firstEightDigits int
for i := 0; i < 8; i++ { for i := 0; i < 8; i++ {
firstEightDigits *= 10 firstEightDigits *= 10
+2 -2
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
@@ -35,7 +35,7 @@ func main() {
fmt.Printf("output received at %v, %v to go\n", time.Now(), 100-i-1) fmt.Printf("output received at %v, %v to go\n", time.Now(), 100-i-1)
} }
// Transform into AoC output // Transform into github.com/alexchao26/advent-of-code-go output
var firstEightDigits int var firstEightDigits int
for i := 0; i < 8; i++ { for i := 0; i < 8; i++ {
firstEightDigits *= 10 firstEightDigits *= 10
+1 -1
View File
@@ -8,7 +8,7 @@ Robot struct houses an Intcode computer and a method to initialize the floor det
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -6,7 +6,7 @@ Robot struct houses an Intcode computer and a method to initialize the floor det
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"math" "math"
"strings" "strings"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"math" "math"
"sort" "sort"
+1 -1
View File
@@ -7,7 +7,7 @@ Intcode struct is defined within this file
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -7,7 +7,7 @@ Intcode struct is defined within this file
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"math" "math"
"strings" "strings"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"math" "math"
"strings" "strings"
+1 -1
View File
@@ -6,7 +6,7 @@ Intcode struct is defined within this file
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -7,7 +7,7 @@ Helper function that converts strings to ASCII codes to be written to the comput
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
+1 -1
View File
@@ -6,7 +6,7 @@ Intcode struct is defined within this file
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
+2 -2
View File
@@ -7,7 +7,7 @@ Network struct to store 50 instances of Intcode computers and 50 queues for thei
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"log" "log"
"strconv" "strconv"
@@ -82,7 +82,7 @@ func main() {
// if all nat computers are waiting for inputs, write the natpacket to // if all nat computers are waiting for inputs, write the natpacket to
// the zero-th computer's queue // the zero-th computer's queue
if allNatsWaiting { if allNatsWaiting {
// check if this packet has a duplicate Y value, if so print AoC output // check if this packet has a duplicate Y value, if so print github.com/alexchao26/advent-of-code-go output
if lastNatY == natPacket[1] { if lastNatY == natPacket[1] {
fmt.Println(lastNatY, "written to NAT twice") fmt.Println(lastNatY, "written to NAT twice")
// stop the infinite loop // stop the infinite loop
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -1,7 +1,7 @@
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"fmt" "fmt"
"strings" "strings"
) )
+1 -1
View File
@@ -6,7 +6,7 @@ Helper function that converts strings to ASCII codes to be written to the comput
package main package main
import ( import (
"adventofcode/util" "github.com/alexchao26/advent-of-code-go/util"
"bufio" "bufio"
"fmt" "fmt"
"log" "log"
+8
View File
@@ -0,0 +1,8 @@
### Scripts
Addition for 2020 event.
path|usage
---|---
scripts/fetchers/cmd-inputs | go run scripts/fetches/cmd-inputs/inputs.go <br>-cookie flag for session cookie from AOC website (required to be set via flag OR on ENV) <br> -day flag defaults to today<br>-year flag defaults to current year
scripts/fetchers/cmd-prompts | go run scripts/fetches/cmd-prompts/prompts.go<br>same flags as inputs script
scripts/template/template.go | go run scripts/template/template.go<br> same -day and -year flags, quickly templates up files for the given day's solutions.<br> Note that functions are meant to be run using `go test -run DayX .` from 2020 folder
+3 -1
View File
@@ -1,3 +1,5 @@
module adventofcode module github.com/alexchao26/advent-of-code-go
go 1.13 go 1.13
require golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
+11
View File
@@ -0,0 +1,11 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+6 -12
View File
@@ -1,18 +1,12 @@
package util package util
// MaxInts takes a variable number of integers and returns the largest one // MaxInts takes a variable number of integers and returns the largest one
func MaxInts(numbers ...int) int { func MaxInts(nums ...int) int {
floats := make([]float64, len(numbers)) maxNum := nums[0]
for i, num := range numbers { for _, v := range nums {
floats[i] = float64(num) if v > maxNum {
} maxNum = v
maxNum := floats[0]
for i := range floats {
if floats[i] > maxNum {
maxNum = floats[i]
} }
} }
return maxNum
return int(maxNum)
} }
+12 -4
View File
@@ -2,8 +2,8 @@ package util
import ( import (
"io/ioutil" "io/ioutil"
"log"
"path" "path"
"path/filepath"
"runtime" "runtime"
"strings" "strings"
) )
@@ -16,8 +16,7 @@ func ReadFile(pathFromCaller string) string {
// Docs: https://golang.org/pkg/runtime/#Caller // Docs: https://golang.org/pkg/runtime/#Caller
_, filename, _, ok := runtime.Caller(1) _, filename, _, ok := runtime.Caller(1)
if !ok { if !ok {
// NOTE this could be updated to make ReadFile return an error, but that's overkill... panic("Could not find Caller of util.ReadFile")
log.Fatal("Could not find Caller of util.ReadFile")
} }
// parse directory with pathFromCaller (which could be relative to Directory) // parse directory with pathFromCaller (which could be relative to Directory)
@@ -26,9 +25,18 @@ func ReadFile(pathFromCaller string) string {
// read the entire file & return the byte slice as a string // read the entire file & return the byte slice as a string
content, err := ioutil.ReadFile(absolutePath) content, err := ioutil.ReadFile(absolutePath)
if err != nil { if err != nil {
log.Fatal(err) panic(err)
} }
// trim off new lines and tabs at end of input files // trim off new lines and tabs at end of input files
strContent := string(content) strContent := string(content)
return strings.TrimRight(strContent, "\n") return strings.TrimRight(strContent, "\n")
} }
// Dirname is a port of __dirname in node
func Dirname() string {
_, filename, _, ok := runtime.Caller(1)
if !ok {
panic("getting calling function")
}
return filepath.Dir(filename)
}
-1
View File
@@ -2,7 +2,6 @@ package util
// RotateGrid returns the inputted grid, rotated counterclockwise // RotateGrid returns the inputted grid, rotated counterclockwise
// call it multiple times for 180, & 270 degree rotations // call it multiple times for 180, & 270 degree rotations
// TODO modify this to take in any type (not just strings...)
func RotateGrid(grid [][]string) [][]string { func RotateGrid(grid [][]string) [][]string {
rotated := make([][]string, len(grid[0])) rotated := make([][]string, len(grid[0]))
for i := range rotated { for i := range rotated {