From 0ece305db087a81f3e2ca3cfd4038f97654ee2d1 Mon Sep 17 00:00:00 2001 From: Michael Bobbitt Date: Fri, 20 Dec 2024 01:08:11 -0500 Subject: [PATCH] added template for easier start --- template/main.go | 36 ++++++++++++++++++++++++++++++++++++ template/run | 4 ++++ 2 files changed, 40 insertions(+) create mode 100644 template/main.go create mode 100755 template/run diff --git a/template/main.go b/template/main.go new file mode 100644 index 0000000..143eb9f --- /dev/null +++ b/template/main.go @@ -0,0 +1,36 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + if len(os.Args) < 2 { + panic("Provide input file") + } + inputFile := os.Args[1] + + part1, part2 := solution(inputFile) + fmt.Printf("(%s) Part 1: %d\n(%s) Part 2: %d\n", inputFile, part1, inputFile, part2) +} + +func solution(inputFile string) (int, int) { + var part1, part2 int + + // Read line by line + // input, err := os.Open(inputFile) + // if err != nil { + // panic(err) + // } + // defer input.Close() + + // read whole file + // input, err := os.ReadFile(inputFile) + // if err != nil { + // panic(err) + // } + // fmt.Println(string(input)) + + return part1, part2 +} diff --git a/template/run b/template/run new file mode 100755 index 0000000..2ea19e2 --- /dev/null +++ b/template/run @@ -0,0 +1,4 @@ +#!/bin/bash + +go build -o ./bin/solution ./main.go +./bin/solution "$1"