Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@
"program": "${workspaceFolder}/2025/day_5",
},
{
"name": "2025 Day 6",
"name": "2025 Day 6 (part 1)",
"type": "go",
"request": "launch",
"mode": "auto",
"cwd": "${workspaceFolder}/2025/day_6",
"program": "${workspaceFolder}/2025/day_6",
},
{
"name": "2025 Day 6 (part 2)",
"type": "go",
"request": "launch",
"mode": "auto",
"cwd": "${workspaceFolder}/2025/day_6/part_2",
"program": "${workspaceFolder}/2025/day_6/part_2",
},
{
"type": "node",
"request": "launch",
Expand Down
2 changes: 1 addition & 1 deletion 2025/day_1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func main() {
d.Turn(d.getAmount())
d.Reset()
default:
d.amount = append(d.amount, si.R)
d.amount = append(d.amount, si.R.Rune())
}
})

Expand Down
2 changes: 1 addition & 1 deletion 2025/day_2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func main() {
s.Pairs = append(s.Pairs, *s.CurrentPair)
s.Reset()
default:
s.Value = append(s.Value, si.R)
s.Value = append(s.Value, si.R.Rune())
}
})
log.Printf("answer: %d", s.Result)
Expand Down
3 changes: 0 additions & 3 deletions 2025/day_6/go.mod

This file was deleted.

11 changes: 11 additions & 0 deletions 2025/day_6/part_1/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module day_6_part_1_aoc_2025

go 1.25.1

require github.com/stretchr/testify v1.11.1

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 10 additions & 0 deletions 2025/day_6/part_1/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
File renamed without changes.
8 changes: 4 additions & 4 deletions 2025/day_6/main.go → 2025/day_6/part_1/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"day_6_aoc_2025/expression"
"day_6_aoc_2025/state"
"day_6_part_1_aoc_2025/expression"
"day_6_part_1_aoc_2025/state"
"log"
shared "shared_aoc_2025"
)
Expand All @@ -27,7 +27,7 @@ func main() {
total += exp.Evaluate()
}
log.Printf("total: %d", total)
}), shared.WithNewlineCallback(func() {
}), shared.WithNewlineCallback(func(si shared.StreamInfo) {
if !s.CurrentOperand().IsEmpty() {
log.Println("not empty")
}
Expand All @@ -42,7 +42,7 @@ func AddToExpression(s *state.State, si shared.StreamInfo) {
if currentOperand.IsEmpty() {
return
}
if si.Line == 1 {
if si.LineNumber == 1 {
exp := expression.NewExpression()
op := currentOperand.Build()
exp.AppendOperand(op)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package state

import "day_6_aoc_2025/expression"
import "day_6_part_1_aoc_2025/expression"

type State struct {
expressions []*expression.Expression
Expand Down
3 changes: 3 additions & 0 deletions 2025/day_6/part_2/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module day_6_part_2_aoc_2025

go 1.25.1
5 changes: 5 additions & 0 deletions 2025/day_6/part_2/input.txt

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions 2025/day_6/part_2/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package main

import (
"log"
shared "shared_aoc_2025"
"strconv"
"strings"
)

type value struct {
strVal string
}

// Int converts the value to an integer.
func (v value) Int() int {
strings.TrimSpace(v.strVal)
intVal, err := strconv.Atoi(v.strVal)
if err != nil {
panic(err)
}
return intVal
}

// IsEmpty checks if the string value is empty.
func (v value) IsEmpty() bool {
return len(strings.Trim(v.strVal, " ")) == 0
}

type column struct {
values []value
operation Operator
}

var (
columns []column
)

func main() {
cv := value{}
colIdx := 0
shared.StreamProcess("test.txt", func(si shared.StreamInfo) {
switch si.R {
case '+', '-', '*', '/':
case '\n', '\r':
cv = value{}
colIdx++
if colIdx >= len(columns) {
colIdx = 0
}
case ' ':
//cv.strVal += si.R.String()
if si.LineNumber == 1 {
//if !cv.IsEmpty() {
columns = append(columns, column{
values: []value{cv},
})
//}
}
cv = value{}
default:
cv.strVal += si.R.String()
}
}, shared.WithEOFCallback(func() {
total := 0
log.Printf("total: %d", total)
}), shared.WithNewlineCallback(func(si shared.StreamInfo) {

}), shared.WithCRCallback(func(si shared.StreamInfo) {

}))
}

// 7098065460541 -- correct
43 changes: 43 additions & 0 deletions 2025/day_6/part_2/operator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import "fmt"

type Operator int

const (
None Operator = iota
Add
Subtract
Multiply
Divide
)

func OperatorFromRune(r rune) Operator {
switch r {
case '+':
return Add
case '-':
return Subtract
case '*':
return Multiply
case '/':
return Divide
default:
panic(fmt.Sprintf("operator not supported: %c", r))
}
}

func (o Operator) String() string {
switch o {
case Add:
return "+"
case Subtract:
return "-"
case Multiply:
return "x"
case Divide:
return "/"
default:
return "None"
}
}
8 changes: 8 additions & 0 deletions 2025/day_6/part_2/state/state.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package state

type State struct {
}

func New() State {
return State{}
}
3 changes: 2 additions & 1 deletion 2025/go.work
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use (
./day_3
./day_4
./day_5
./day_6
./day_6/part_1
./day_6/part_2
./shared
)
17 changes: 17 additions & 0 deletions 2025/shared/character.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package shared

type Character rune

const (
Newline rune = '\n'
CarriageReturn rune = '\r'
Space rune = ' '
)

func (c Character) String() string {
return string(c)
}

func (c Character) Rune() rune {
return rune(c)
}
Loading