mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-27 22:59:18 +02:00
cleanup tests
updated 2020 templates for easier addition of tests
This commit is contained in:
+33
-21
@@ -14,31 +14,43 @@ var arg1 = `1, 1
|
||||
8, 9
|
||||
`
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
want := 17
|
||||
got := part1(arg1)
|
||||
if got != want {
|
||||
t.Errorf("arg1: wanted %d, got %d", want, got)
|
||||
}
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
}{
|
||||
{"example1", 17, arg1},
|
||||
{"actual", 5333, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
// Run actual problem input
|
||||
want = 5333
|
||||
got = part1(util.ReadFile("input.txt"))
|
||||
if got != want {
|
||||
t.Errorf("actual AOC input, wanted %d, got %d", want, got)
|
||||
func TestPart1(t *testing.T) {
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
distArg int
|
||||
}{
|
||||
{"example1", 16, arg1, 32},
|
||||
{"actual", 35334, util.ReadFile("input.txt"), 10000},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
distArg := 32
|
||||
want := 16
|
||||
got := part2(arg1, distArg)
|
||||
if got != want {
|
||||
t.Errorf("part2(arg1, %v): want %v, got %v", distArg, want, got)
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input, test.distArg)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
}
|
||||
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
|
||||
--- Day 6: Chronal Coordinates ---
|
||||
The device on your wrist beeps several times, and once again you feel like you're falling.
|
||||
|
||||
|
||||
"Situation critical," the device announces. "Destination indeterminate. Chronal interference detected. Please specify new target coordinates."
|
||||
|
||||
|
||||
The device then produces a list of coordinates (your puzzle input). Are they places it thinks are safe or dangerous? It recommends you check manual page 729. The Elves did not give you a manual.
|
||||
|
||||
|
||||
If they're dangerous, maybe you can minimize the danger by finding the coordinate that gives the largest distance from the other points.
|
||||
|
||||
|
||||
Using only the Manhattan distance, determine the area around each coordinate by counting the number of integer X,Y locations that are closest to that coordinate (and aren't tied in distance to any other coordinate).
|
||||
|
||||
|
||||
Your goal is to find the size of the largest area that isn't infinite. For example, consider the following list of coordinates:
|
||||
|
||||
|
||||
1, 1
|
||||
1, 6
|
||||
8, 3
|
||||
3, 4
|
||||
5, 5
|
||||
8, 9
|
||||
|
||||
|
||||
|
||||
If we name these coordinates A through F, we can draw them on a grid, putting 0,0 at the top left:
|
||||
|
||||
|
||||
..........
|
||||
.A........
|
||||
..........
|
||||
........C.
|
||||
...D......
|
||||
.....E....
|
||||
.B........
|
||||
..........
|
||||
..........
|
||||
........F.
|
||||
|
||||
|
||||
|
||||
This view is partial - the actual grid extends infinitely in all directions. Using the Manhattan distance, each location's closest coordinate can be determined, shown here in lowercase:
|
||||
|
||||
|
||||
aaaaa.cccc
|
||||
aAaaa.cccc
|
||||
aaaddecccc
|
||||
aadddeccCc
|
||||
..dDdeeccc
|
||||
bb.deEeecc
|
||||
bBb.eeee..
|
||||
bbb.eeefff
|
||||
bbb.eeffff
|
||||
bbb.ffffFf
|
||||
|
||||
|
||||
|
||||
Locations shown as . are equally far from two or more coordinates, and so they don't count as being closest to any.
|
||||
|
||||
|
||||
In this example, the areas of coordinates A, B, C, and F are infinite - while not shown here, their areas extend forever outside the visible grid. However, the areas of coordinates D and E are finite: D is closest to 9 locations, and E is closest to 17 (both including the coordinate's location itself). Therefore, in this example, the size of the largest area is 17.
|
||||
|
||||
|
||||
What is the size of the largest area that isn't infinite?
|
||||
|
||||
|
||||
--- Part Two ---
|
||||
On the other hand, if the coordinates are safe, maybe the best you can do is try to find a region near as many coordinates as possible.
|
||||
|
||||
|
||||
For example, suppose you want the sum of the Manhattan distance to all of the coordinates to be less than 32. For each location, add up the distances to all of the given coordinates; if the total of those distances is less than 32, that location is within the desired region. Using the same coordinates as above, the resulting region looks like this:
|
||||
|
||||
|
||||
..........
|
||||
.A........
|
||||
..........
|
||||
...###..C.
|
||||
..#D###...
|
||||
..###E#...
|
||||
.B.###....
|
||||
..........
|
||||
..........
|
||||
........F.
|
||||
|
||||
|
||||
|
||||
In particular, consider the highlighted location 4,3 located at the top middle of the region. Its calculation is as follows, where abs() is the absolute value function:
|
||||
|
||||
|
||||
|
||||
Distance to coordinate A: abs(4-1) + abs(3-1) = 5
|
||||
Distance to coordinate B: abs(4-1) + abs(3-6) = 6
|
||||
Distance to coordinate C: abs(4-8) + abs(3-3) = 4
|
||||
Distance to coordinate D: abs(4-3) + abs(3-4) = 2
|
||||
Distance to coordinate E: abs(4-5) + abs(3-5) = 3
|
||||
Distance to coordinate F: abs(4-8) + abs(3-9) = 10
|
||||
Total distance: 5 + 6 + 4 + 2 + 3 + 10 = 30
|
||||
|
||||
|
||||
|
||||
Because the total distance to all coordinates (30) is less than 32, the location is within the region.
|
||||
|
||||
|
||||
This region, which also includes coordinates D and E, has a total size of 16.
|
||||
|
||||
|
||||
Your actual region will need to be much larger than this example, though, instead including all locations with a total distance of less than 10000.
|
||||
|
||||
|
||||
What is the size of the region containing all locations which have a total distance to all given coordinates of less than 10000?
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+35
-13
@@ -1,21 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,24 +17,46 @@ type TemplateData struct {
|
||||
|
||||
var testTemplateString = `package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
var tests1 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part1(util.ReadFile("input.txt"))
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part1(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
want int
|
||||
input string
|
||||
// add extra args if needed
|
||||
}{
|
||||
// {"actual", /* ACTUAL ANSWER */, util.ReadFile("input.txt")},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
// Examples
|
||||
|
||||
// Run actual problem input
|
||||
// part2(util.ReadFile("input.txt"))
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("want %v, got %v", test.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
@@ -104,6 +126,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// note: data is no longer used, but keeping it for future reference of text/template
|
||||
solutionTemp.Execute(solutionWriter, data)
|
||||
testTemp.Execute(testWriter, data)
|
||||
fmt.Println("templates made")
|
||||
|
||||
Reference in New Issue
Block a user