File tree Expand file tree Collapse file tree 9 files changed +30
-8
lines changed
Expand file tree Collapse file tree 9 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
1212 "github.com/pkg/errors"
1313
1414 "github.com/oleg-balunenko/advent-of-code/puzzles"
15- _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions/day01"
15+ _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions/2019/ day01"
1616)
1717
1818const (
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ // Package day01 solves https://adventofcode.com/2019/day/1
12package day01
23
34import (
@@ -10,27 +11,27 @@ import (
1011 "github.com/oleg-balunenko/advent-of-code/puzzles"
1112)
1213
13- type solver struct {
14+ type solution struct {
1415 name string
1516}
1617
1718func init () {
1819 const puzzleName = "day01"
1920
20- puzzles .Register (puzzleName , solver {
21+ puzzles .Register (puzzleName , solution {
2122 name : puzzleName ,
2223 })
2324}
2425
25- func (s solver ) Part1 (input io.Reader ) (string , error ) {
26+ func (s solution ) Part1 (input io.Reader ) (string , error ) {
2627 return calc (input , calcPart1 )
2728}
2829
29- func (s solver ) Part2 (input io.Reader ) (string , error ) {
30+ func (s solution ) Part2 (input io.Reader ) (string , error ) {
3031 return calc (input , calcPart2 )
3132}
3233
33- func (s solver ) Name () string {
34+ func (s solution ) Name () string {
3435 return s .name
3536}
3637
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ func Test_solver_Part1(t *testing.T) {
215215 tt := tt
216216
217217 t .Run (tt .name , func (t * testing.T ) {
218- s := solver {
218+ s := solution {
219219 name : tt .fields .name ,
220220 }
221221 input := readerFromFile (t , tt .args .inputPath )
@@ -265,7 +265,7 @@ func Test_solver_Part2(t *testing.T) {
265265 tt := tt
266266
267267 t .Run (tt .name , func (t * testing.T ) {
268- s := solver {
268+ s := solution {
269269 name : tt .fields .name ,
270270 }
271271 input := readerFromFile (t , tt .args .inputPath )
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ // Package declares common interface for puzzle solutions and functionality for register and run them.
2+ package solutions
3+
4+ // Each solution should implement `Solver` interface, be implemented udnder separate package and contain `init()`
5+ // function that will register that solution in list of all solvers.
6+
7+ // type solver struct {
8+ // name string
9+ // }
10+ //
11+ // func init() {
12+ // const puzzleName = "day01"
13+ // puzzles.Register(puzzleName, solver{
14+ // name: puzzleName,
15+ // })
16+ // }
17+
18+ // Then to register solution in the list of all solutions: make a blank import of package with puzzle solution
19+ // at main.go
20+ //
21+ // _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions/day01"
You can’t perform that action at this time.
0 commit comments