mirror of
https://github.com/onyx-and-iris/aoc2023.git
synced 2024-11-24 19:30:48 +00:00
35 lines
527 B
Go
35 lines
527 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
// readlines reads lines from stdin.
|
|
// Then it returns them as an array of strings
|
|
func readlines() []string {
|
|
lines := []string{}
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
for scanner.Scan() {
|
|
lines = append(lines, scanner.Text())
|
|
}
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
return lines
|
|
}
|
|
|
|
// anyTrue checks if any digits passed
|
|
func anyTrue(digits []digit) bool {
|
|
for _, digit := range digits {
|
|
if digit.pass {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|