Compare commits

..

1 Commits

Author SHA1 Message Date
xuu
cb2b6087b7
chore: add day 10 pt1
Some checks failed
Go Test / build (pull_request) Failing after 20s
2023-12-10 12:03:19 -07:00
2 changed files with 18 additions and 24 deletions

View File

@ -29,7 +29,7 @@ func run(scan *bufio.Scanner) (*result, error) {
}
dist := m.buildPath()
return &result{valuePT1: dist}, nil
}
@ -75,19 +75,19 @@ func (m *Path) readLine(text string) {
}
func (m *Path) buildPath() int {
m.start()
log(m.n)
// log(m.n)
i := 0
for m.next() {
log(m.n)
// log(m.n)
i++
}
log(m.n)
log("length", (m.l+2)/2)
// log(m.n)
// log("length", (m.l+2)/2)
return (m.l+2)/2
}
func (m *Path) start() {
m.n = &node{value: 'S', pos: m.s}
log(m.n)
// log(m.n)
switch {
case m.peek(UP) != nil:

View File

@ -34,11 +34,8 @@ func TestExample1(t *testing.T) {
result, err := run(scan)
is.NoErr(err)
t.Log(result.valuePT1)
// t.Log(result.valuePT1)
is.Equal(result.valuePT1, 4)
t.Log(result.valuePT2)
is.Equal(result.valuePT2, uint64(0))
}
func TestExample2(t *testing.T) {
@ -48,11 +45,8 @@ func TestExample2(t *testing.T) {
result, err := run(scan)
is.NoErr(err)
t.Log(result.valuePT1)
// t.Log(result.valuePT1)
is.Equal(result.valuePT1, 8)
t.Log(result.valuePT2)
is.Equal(result.valuePT2, uint64(0))
}
func TestExample3(t *testing.T) {
@ -62,10 +56,10 @@ func TestExample3(t *testing.T) {
result, err := run(scan)
is.NoErr(err)
t.Log(result.valuePT1)
// t.Log(result.valuePT1)
is.Equal(result.valuePT1, 23)
t.Log(result.valuePT2)
// t.Log(result.valuePT2)
is.Equal(result.valuePT2, 4)
}
@ -76,10 +70,10 @@ func TestExample4(t *testing.T) {
result, err := run(scan)
is.NoErr(err)
t.Log(result.valuePT1)
// t.Log(result.valuePT1)
is.Equal(result.valuePT1, 70)
t.Log(result.valuePT2)
// t.Log(result.valuePT2)
is.Equal(result.valuePT2, 8)
}
@ -90,10 +84,10 @@ func TestExample5(t *testing.T) {
result, err := run(scan)
is.NoErr(err)
t.Log(result.valuePT1)
// t.Log(result.valuePT1)
is.Equal(result.valuePT1, 80)
t.Log(result.valuePT2)
// t.Log(result.valuePT2)
is.Equal(result.valuePT2, 10)
}
@ -104,12 +98,12 @@ func TestInput(t *testing.T) {
result, err := run(scan)
is.NoErr(err)
t.Log(result.valuePT1)
t.Log(result.valuePT1 != 51)
// t.Log(result.valuePT1)
is.True(result.valuePT1 != 51)
is.Equal(result.valuePT1, 6649)
t.Log(result.valuePT2)
is.Equal(result.valuePT2, uint64(0))
// t.Log(result.valuePT2)
is.True(result.valuePT2 != 0)
}
// first: 51 false