day3, part1

This commit is contained in:
efim
2023-12-03 07:20:27 +00:00
parent c9f9766866
commit b767ef256d
2 changed files with 145 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ import (
)
func Run() int {
filename := "day3/example"
filename := "day3/input"
bytes, err := os.ReadFile(filename)
if err != nil {
panic(fmt.Sprint(err, filename))
@@ -20,7 +20,9 @@ func Run() int {
fmt.Println(matrix.String())
numbers := ReadNumbers(&matrix)
fmt.Println(numbers)
for _, num := range numbers {
fmt.Println(num)
}
partNumbersSum := 0
for _, num := range numbers {
@@ -114,7 +116,7 @@ func ReadNumbers(m *Matrix) []MatrixNumber {
// now let's check for special symbols around and save them
}
if symb == '.' {
if !unicode.IsDigit(symb) {
if curNum != nil {
res = append(res, *curNum)
curNum = nil