Browse Source

Add stub file

master
Elis Hirwing 10 months ago
parent
commit
a35942e397
Signed by: etu GPG Key ID: D57EFA625C9A925F
  1. 58
      main.stub.go

58
main.stub.go

@ -0,0 +1,58 @@
package main // import "git.elis.nu/etu/aoc2019/dayX"
import (
"bufio"
"fmt"
"log"
"os"
"time"
)
func main() {
log.Println("Starting program to solve 2019-12-XX")
// Store time to print out execution time
start := time.Now()
var rows []string
// Get file handler
file, err := os.Open(os.Args[1])
defer file.Close()
if err != nil {
log.Fatal("Failed to open file:", err)
}
// Begin parsing file
scanner := bufio.NewScanner(file)
for scanner.Scan() {
rows = append(rows, scanner.Text())
}
// Print eventual error from parsing the file
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
// Log spent time
log.Printf("Spent %s on parsing input\n", time.Since(start))
start = time.Now()
part1(rows)
log.Printf("Spent %s on solving part1\n", time.Since(start))
start = time.Now()
part2(rows)
log.Printf("Spent %s on solving part2\n", time.Since(start))
}
func part1(rows []string) {
fmt.Println(rows)
}
func part2(rows []string) {
fmt.Println(rows)
}
Loading…
Cancel
Save