mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-18 11:03:27 +02:00
renamed module... for some reason
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -67,7 +67,7 @@ func main() {
|
||||
}
|
||||
|
||||
// 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,
|
||||
bestMinute,
|
||||
IDOfSleepiestGuard*bestMinute,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -59,7 +59,7 @@ func main() {
|
||||
}
|
||||
|
||||
// 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,
|
||||
bestMinute,
|
||||
ID*bestMinute,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -28,7 +28,7 @@ func main() {
|
||||
|
||||
// run step on the cloned slice
|
||||
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 {
|
||||
// print answers to console (manually add to advent of code)
|
||||
fmt.Println("noun is", i, "verb is", j)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"adventofcode/2019/day10/part2/trig"
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/2019/day10/part2/trig"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -98,7 +98,7 @@ func main() {
|
||||
|
||||
// print the last used asteroid
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ MakePermutations is in the util package as that will likely be reused
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -9,7 +9,7 @@ Draw function generates a string to display in terminal
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -9,7 +9,7 @@ Draw function generates a string to display in terminal
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -10,7 +10,7 @@ NOTE: The "hold for an input" value was changed from -1 to -2 in the Intcode com
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -9,7 +9,7 @@ Robot struct houses an Intcode computer and its RecursiveMove method populates a
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
|
||||
@@ -12,7 +12,7 @@ Robot struct houses an Intcode computer and its RecursiveMove method populates a
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
@@ -28,7 +28,7 @@ func main() {
|
||||
digits = getNextOutputNumber(digits, patterns)
|
||||
}
|
||||
|
||||
// Transform into AoC output
|
||||
// Transform into github.com/alexchao26/advent-of-code-go output
|
||||
var firstEightDigits int
|
||||
for i := 0; i < 8; i++ {
|
||||
firstEightDigits *= 10
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -35,7 +35,7 @@ func main() {
|
||||
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
|
||||
for i := 0; i < 8; i++ {
|
||||
firstEightDigits *= 10
|
||||
|
||||
@@ -8,7 +8,7 @@ Robot struct houses an Intcode computer and a method to initialize the floor det
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -6,7 +6,7 @@ Robot struct houses an Intcode computer and a method to initialize the floor det
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
|
||||
@@ -7,7 +7,7 @@ Intcode struct is defined within this file
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -7,7 +7,7 @@ Intcode struct is defined within this file
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
@@ -6,7 +6,7 @@ Intcode struct is defined within this file
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -7,7 +7,7 @@ Helper function that converts strings to ASCII codes to be written to the comput
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -6,7 +6,7 @@ Intcode struct is defined within this file
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -7,7 +7,7 @@ Network struct to store 50 instances of Intcode computers and 50 queues for thei
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
@@ -82,7 +82,7 @@ func main() {
|
||||
// if all nat computers are waiting for inputs, write the natpacket to
|
||||
// the zero-th computer's queue
|
||||
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] {
|
||||
fmt.Println(lastNatY, "written to NAT twice")
|
||||
// stop the infinite loop
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ Helper function that converts strings to ASCII codes to be written to the comput
|
||||
package main
|
||||
|
||||
import (
|
||||
"adventofcode/util"
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
@@ -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
|
||||
@@ -1,3 +1,5 @@
|
||||
module adventofcode
|
||||
module github.com/alexchao26/advent-of-code-go
|
||||
|
||||
go 1.13
|
||||
|
||||
require golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
|
||||
|
||||
@@ -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
@@ -1,18 +1,12 @@
|
||||
package util
|
||||
|
||||
// MaxInts takes a variable number of integers and returns the largest one
|
||||
func MaxInts(numbers ...int) int {
|
||||
floats := make([]float64, len(numbers))
|
||||
for i, num := range numbers {
|
||||
floats[i] = float64(num)
|
||||
}
|
||||
|
||||
maxNum := floats[0]
|
||||
for i := range floats {
|
||||
if floats[i] > maxNum {
|
||||
maxNum = floats[i]
|
||||
func MaxInts(nums ...int) int {
|
||||
maxNum := nums[0]
|
||||
for _, v := range nums {
|
||||
if v > maxNum {
|
||||
maxNum = v
|
||||
}
|
||||
}
|
||||
|
||||
return int(maxNum)
|
||||
return maxNum
|
||||
}
|
||||
|
||||
+12
-4
@@ -2,8 +2,8 @@ package util
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
@@ -16,8 +16,7 @@ func ReadFile(pathFromCaller string) string {
|
||||
// Docs: https://golang.org/pkg/runtime/#Caller
|
||||
_, filename, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
// NOTE this could be updated to make ReadFile return an error, but that's overkill...
|
||||
log.Fatal("Could not find Caller of util.ReadFile")
|
||||
panic("Could not find Caller of util.ReadFile")
|
||||
}
|
||||
|
||||
// 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
|
||||
content, err := ioutil.ReadFile(absolutePath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
panic(err)
|
||||
}
|
||||
// trim off new lines and tabs at end of input files
|
||||
strContent := string(content)
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package util
|
||||
|
||||
// RotateGrid returns the inputted grid, rotated counterclockwise
|
||||
// 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 {
|
||||
rotated := make([][]string, len(grid[0]))
|
||||
for i := range rotated {
|
||||
|
||||
Reference in New Issue
Block a user