mirror of
https://github.com/RussellChamp/advent-of-code-2021.git
synced 2026-10-27 21:52:32 +00:00
improved template added timer
This commit is contained in:
1 parent
f6f6a849ec
commit
2992d3ba43
4 files changed
+62
-21
No files matched your search
+37
-18
@@ -1,7 +1,8 @@
|
||||
/* Day #: */
|
||||
/* Day #DAY#: #TITLE# */
|
||||
package main
|
||||
|
||||
import (
|
||||
"AoC2021/utils/timer"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -14,24 +15,42 @@ func check(e error) {
|
||||
}
|
||||
}
|
||||
|
||||
func ReadAllLines(input *os.File) []string {
|
||||
scanner := bufio.NewScanner(input)
|
||||
var text []string
|
||||
for scanner.Scan() {
|
||||
text = append(text, scanner.Text())
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("--- Day #DAY#: #TITLE# ---")
|
||||
timer.Start()
|
||||
part1()
|
||||
timer.Tick()
|
||||
fmt.Println()
|
||||
|
||||
input1, err := os.Open("./input.txt")
|
||||
check(err)
|
||||
|
||||
text := ReadAllLines(input1)
|
||||
input1.Close()
|
||||
|
||||
fmt.Printf("Read %d lines from %s\n", len(text), "input.txt")
|
||||
|
||||
part2()
|
||||
timer.Tick()
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func part1() {
|
||||
fmt.Println("* Part 1 *")
|
||||
fmt.Println(" Goal: ")
|
||||
fmt.Println(" Answer: ")
|
||||
|
||||
input, err := os.Open("./input.txt")
|
||||
check(err)
|
||||
defer input.Close()
|
||||
|
||||
scanner := bufio.NewScanner(input)
|
||||
lines := 0
|
||||
answer := 42
|
||||
|
||||
for scanner.Scan() {
|
||||
_ = scanner.Text()
|
||||
lines++
|
||||
}
|
||||
|
||||
fmt.Printf("Read %d lines from input\n", lines)
|
||||
fmt.Printf("The solution is %d\n", answer)
|
||||
}
|
||||
|
||||
func part2() {
|
||||
fmt.Println("* Part 2 *")
|
||||
fmt.Println(" Goal: ")
|
||||
fmt.Println(" Answer: ")
|
||||
}
|
||||
Reference in new issue
Block a user