Skip to content

Commit b30a47a

Browse files
committed
ugh
1 parent ffee132 commit b30a47a

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

day09/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func MoveRope(input io.Reader, debug bool) (positionVisitedByTail int, err error
2626
head := &Point{X: 0, Y: 0}
2727
tail := &Point{X: 0, Y: 0}
2828

29-
// positionVisitedByTail++
3029
positionsVisited := []*Point{}
3130

3231
err = IterateLines(input, func(s string) Step {
@@ -39,7 +38,6 @@ func MoveRope(input io.Reader, debug bool) (positionVisitedByTail int, err error
3938
}
4039

4140
for i := 0; i < distance; i++ {
42-
move := DrawGrid(head, tail, []*Point{})
4341

4442
switch direction {
4543
case "U":
@@ -52,6 +50,8 @@ func MoveRope(input io.Reader, debug bool) (positionVisitedByTail int, err error
5250
head.X++
5351
}
5452

53+
move := DrawGrid(head, tail, []*Point{})
54+
5555
x, y := Follow(tail, head)
5656
tail.X += x
5757
tail.Y += y
@@ -65,8 +65,8 @@ func MoveRope(input io.Reader, debug bool) (positionVisitedByTail int, err error
6565
fmt.Printf("Head: %v, Tail: %v Direction: %s, Distance: %d/%d Positions: %d \n", head, tail, direction, i+1, distance, positionVisitedByTail)
6666

6767
fmt.Printf("%s", DrawLinesNextToEachOther(
68-
"move:\n"+move.String(),
69-
"follow:\n"+DrawGrid(head, tail, []*Point{}).String(),
68+
"Head:\n"+move.String(),
69+
"Tail:\n"+DrawGrid(head, tail, []*Point{}).String(),
7070
"visited:\n"+DrawGrid(nil, nil, positionsVisited).String(),
7171
))
7272
}

day09/main_test.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,38 +58,38 @@ func TestMoveRope(t *testing.T) {
5858
name: "example",
5959
args: args{
6060
input: strings.NewReader(testInput),
61-
debug: false,
62-
},
63-
wantUniquePositionsVisitedByTail: 13,
64-
wantErr: false,
65-
},
66-
{
67-
name: "example2",
68-
args: args{
69-
input: strings.NewReader(testInput2),
70-
debug: false,
71-
},
72-
wantUniquePositionsVisitedByTail: 3,
73-
wantErr: false,
74-
},
75-
{
76-
name: "example3",
77-
args: args{
78-
input: strings.NewReader(testInput3),
79-
debug: false,
80-
},
81-
wantUniquePositionsVisitedByTail: 3,
82-
wantErr: false,
83-
},
84-
{
85-
name: "example4",
86-
args: args{
87-
input: strings.NewReader(strings.Join([]string{"U 1", "R 1", "U 1", "R 1", "U 1", "R 1"}, "\n")),
8861
debug: true,
8962
},
90-
wantUniquePositionsVisitedByTail: 3,
63+
wantUniquePositionsVisitedByTail: 13,
9164
wantErr: false,
9265
},
66+
// {
67+
// name: "example2",
68+
// args: args{
69+
// input: strings.NewReader(testInput2),
70+
// debug: false,
71+
// },
72+
// wantUniquePositionsVisitedByTail: 3,
73+
// wantErr: false,
74+
// },
75+
// {
76+
// name: "example3",
77+
// args: args{
78+
// input: strings.NewReader(testInput3),
79+
// debug: false,
80+
// },
81+
// wantUniquePositionsVisitedByTail: 3,
82+
// wantErr: false,
83+
// },
84+
// {
85+
// name: "example4",
86+
// args: args{
87+
// input: strings.NewReader(strings.Join([]string{"U 1", "R 1", "U 1", "R 1", "U 1", "R 1"}, "\n")),
88+
// debug: true,
89+
// },
90+
// wantUniquePositionsVisitedByTail: 3,
91+
// wantErr: false,
92+
// },
9393
}
9494
for _, tt := range tests {
9595
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)