From c6b57d6e8af4d7801625467856d0fb5069d29790 Mon Sep 17 00:00:00 2001 From: David Ashby Date: Tue, 30 Nov 2021 18:51:56 -0500 Subject: [PATCH] add helper scripts --- main.go.tmpl | 37 +++++++++++++++++++++++++++++++++++++ new.sh | 7 +++++++ run.sh | 7 +++++++ 3 files changed, 51 insertions(+) create mode 100644 main.go.tmpl create mode 100755 new.sh create mode 100755 run.sh diff --git a/main.go.tmpl b/main.go.tmpl new file mode 100644 index 0000000..56b5788 --- /dev/null +++ b/main.go.tmpl @@ -0,0 +1,37 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "time" +) + +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 partOne() { + f, _ := os.Open("input") + reader := bufio.NewReader(f) + scanner := bufio.NewScanner(reader) + + for scanner.Scan() { + // line := scanner.Text() + } +} + +func partTwo() { + f, _ := os.Open("input") + reader := bufio.NewReader(f) + scanner := bufio.NewScanner(reader) + + for scanner.Scan() { + // line := scanner.Text() + } +} \ No newline at end of file diff --git a/new.sh b/new.sh new file mode 100755 index 0000000..b1afc57 --- /dev/null +++ b/new.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ "${1}" != "" ]; then + mkdir -p ${1} + touch ${1}/{input,testinput} + cp -n main.go.tmpl ${1}/main.go +fi diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e114129 --- /dev/null +++ b/run.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ "${1}" != "" ]; then + cd ${1} + go run *.go + cd - > /dev/null +fi