Use 'helpers' module for previous days
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
helpers "git.bullercodeworks.com/brian/adventofcode/helpers"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const MaxInt = int(^uint(0) >> 1)
|
||||
|
||||
func main() {
|
||||
inp := StdinToStringSlice()
|
||||
inp := helpers.StdinToStringSlice()
|
||||
part1(inp)
|
||||
}
|
||||
|
||||
@@ -69,7 +66,7 @@ func NewWire() *Wire {
|
||||
|
||||
func (w *Wire) Go(cmd string) {
|
||||
dir := cmd[0]
|
||||
length := Atoi(cmd[1:])
|
||||
length := helpers.Atoi(cmd[1:])
|
||||
for length > 0 {
|
||||
w.Move(dir)
|
||||
w.path = append(w.path, w.curr)
|
||||
@@ -105,21 +102,3 @@ func (c Coord) string() string {
|
||||
func manhattanDistance(x1, y1, x2, y2 int) int {
|
||||
return int(math.Abs(float64(x1)-float64(x2)) + math.Abs(float64(y1)-float64(y2)))
|
||||
}
|
||||
|
||||
func StdinToStringSlice() []string {
|
||||
var input []string
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
input = append(input, scanner.Text())
|
||||
}
|
||||
return input
|
||||
}
|
||||
|
||||
func Atoi(i string) int {
|
||||
var ret int
|
||||
var err error
|
||||
if ret, err = strconv.Atoi(i); err != nil {
|
||||
log.Fatal("Invalid Atoi")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
Reference in New Issue
Block a user