51 lines
787 B
Go
51 lines
787 B
Go
package aoc
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func stdinToStringSlice() []string {
|
|
var input []string
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
for scanner.Scan() {
|
|
input = append(input, scanner.Text())
|
|
}
|
|
return input
|
|
}
|
|
|
|
func itoa(i int) string {
|
|
return strconv.Itoa(i)
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
func stdinToString() string {
|
|
var input string
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
for scanner.Scan() {
|
|
input += scanner.Text()
|
|
}
|
|
return input
|
|
}
|
|
|
|
func fileToString(fn string) string {
|
|
var c []byte
|
|
c, err = ioutil.Readfile(filename)
|
|
if err != nil {
|
|
fmt.Println("Unable to read file: " + filename)
|
|
os.Exit(1)
|
|
}
|
|
return string(c)
|
|
}
|