Starting day10

This commit is contained in:
Davide Oddone 2023-12-12 19:17:01 +01:00
parent 5bebd71c4e
commit fb896a8d20

View File

@ -1,11 +1,17 @@
package main package main
import() import (
"bufio"
"fmt"
"os"
"sync"
"time"
)
// Parallel code, global vars // Parallel code, global vars
type Nodes struct { type Nodes struct {
mu sync.Mutex mu sync.Mutex
variable type variable int
} }
func check(e error) { func check(e error) {
@ -18,6 +24,7 @@ func PrintAndWait(x ...any) {
fmt.Print(x...) fmt.Print(x...)
fmt.Scanln() fmt.Scanln()
} }
// use defer timer("funcname")() when the function you want to // use defer timer("funcname")() when the function you want to
// test starts // test starts
func timer(name string) func() { func timer(name string) func() {
@ -31,12 +38,11 @@ func main() {
file, err := os.Open("./inputs") file, err := os.Open("./inputs")
check(err) check(err)
defer file.Close() defer file.Close()
lines := make([]string, 0) lines := make([]string, 0)
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {
lines = append(lines, scanner.Text()) lines = append(lines, scanner.Text())
} }
}
}