diff --git a/03/main.go b/03/main.go new file mode 100644 index 0000000..0d3fbc3 --- /dev/null +++ b/03/main.go @@ -0,0 +1,50 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" + "time" +) + +func mustAtoi(line string) int { + i, _ := strconv.Atoi(line) + return i +} + +func main() { + start := time.Now() + partOne() + duration := time.Since(start) + partTwo() + duration2 := time.Since(start) + fmt.Printf("p1: %s, p2: %s\n", duration, duration2-duration) +} + +func makeScanner(test bool) *bufio.Scanner { + var f *os.File + if test { + f, _ = os.Open("inputs/testinput") + } else { + f, _ = os.Open("inputs/input") + } + reader := bufio.NewReader(f) + return bufio.NewScanner(reader) +} + +func partOne() { + scanner := makeScanner(false) + + for scanner.Scan() { + // line := scanner.Text() + } +} + +func partTwo() { + scanner := makeScanner(false) + + for scanner.Scan() { + // line := scanner.Text() + } +} diff --git a/main.scm.tmpl b/main.scm.tmpl deleted file mode 100644 index dd71f64..0000000 --- a/main.scm.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -(import - (chicken io) - (chicken format) -) - -(define print-line - (lambda (line) - (printf "~A~%" line))) - -(call-with-input-file "inputs/input" - (lambda (port) - (map - print-line - (read-lines port)))) - -(call-with-input-file "inputs/input" - (lambda (port) - (map - print-line - (read-lines port)))) \ No newline at end of file diff --git a/new.sh b/new.sh index 973d08b..2ba9c4d 100755 --- a/new.sh +++ b/new.sh @@ -14,8 +14,5 @@ if [ "${1}" != "" ]; then if [ ! -f "${padded}/main.go" ]; then cp -n main.go.tmpl ${padded}/main.go fi - # if [ ! -f "${padded}/main.scm" ]; then - # cp -n main.scm.tmpl ${padded}/main.scm - # fi echo "https://adventofcode.com/${__year}/day/${1}" fi diff --git a/readme.md b/readme.md index 7c4fddb..a3155ea 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,7 @@ # AOC 2023 -In Chicken Scheme? Perhaps. Go as a fallback. +~~In Chicken Scheme? Perhaps.~~Like I actually have time to learn Scheme's idioms with a six-month-old in the house. + +Go as a fallback. diff --git a/run.sh b/run.sh index 609d362..dce9523 100755 --- a/run.sh +++ b/run.sh @@ -3,11 +3,6 @@ if [ "${1}" != "" ]; then padded=$(printf "%02g" ${1}) cd ${padded} - if [ "${2}" == "go" ]; then - go run main.go - fi - if [ "${2}" == "csi" ]; then - csi -s main.scm - fi + go run main.go cd - > /dev/null fi