From c6150871a3a7984a0be58a8905f4a00a21595bba Mon Sep 17 00:00:00 2001 From: Davide Oddone Date: Sun, 10 Dec 2023 20:04:59 +0100 Subject: [PATCH] Added generic template for almost every day --- template.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 template.go diff --git a/template.go b/template.go new file mode 100644 index 0000000..11194e8 --- /dev/null +++ b/template.go @@ -0,0 +1,42 @@ +package main + +import() + +// Parallel code, global vars +type Nodes struct { + mu sync.Mutex + variable type +} + +func check(e error) { + if e != nil { + panic(e) + } +} + +func PrintAndWait(x ...any) { + fmt.Print(x...) + fmt.Scanln() +} +// use defer timer("funcname")() when the function you want to +// test starts +func timer(name string) func() { + start := time.Now() + return func() { + fmt.Printf("%s took %v\n", name, time.Since(start)) + } +} + +func main() { + file, err := os.Open("./inputs") + check(err) + defer file.Close() + + lines := make([]string, 0) + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + +}