Skip to content

Commit 6f23bd1

Browse files
committed
2017.1-12 cleanup
1 parent 4c6937f commit 6f23bd1

14 files changed

+74
-34
lines changed

01_sums.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import (
88
)
99

1010
func main() {
11-
for p := range source.Test(1, `91212129`, `9`).Test(2, `12131415`, `4`).Advent(2017, 1) {
11+
var ins source.Inputs
12+
13+
ins = ins.Test(1, `91212129`, `9`)
14+
ins = ins.Test(2, `12131415`, `4`)
15+
16+
for p := range ins.Advent(2017, 1) {
1217
fmt.Println(Brown("\n" + p.Name))
1318
in := p.Val
1419

02_sums.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ var test2 = `5 9 2 8
1717
3 8 6 5`
1818

1919
func main() {
20-
for p := range source.Test(1, test1, `18`).Test(2, test2, `9`).Advent(2017, 2) {
20+
var ins source.Inputs
21+
22+
ins = ins.Test(1, test1, `18`)
23+
ins = ins.Test(2, test2, `9`)
24+
25+
for p := range ins.Advent(2017, 2) {
2126
fmt.Println(Brown("\n" + p.Name))
2227
ssn := p.Lines().Ints()
2328

03_spiral_map.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ func walkSpiral(f field.Field, fn func(int, field.Pos) bool) field.Pos {
3333
}
3434

3535
func main() {
36-
for in := range source.Test(1, `23`, `2`).Test(1, `1024`, `31`).Test(2, `60`, `122`).Advent(2017, 3) {
36+
var ins source.Inputs
37+
38+
ins = ins.Test(1, `23`, `2`)
39+
ins = ins.Test(1, `1024`, `31`)
40+
ins = ins.Test(2, `60`, `122`)
41+
42+
for in := range ins.Advent(2017, 3) {
3743
fmt.Println(Brown("\n" + in.Name))
3844
n := in.Ints()[0]
3945
fmt.Println(Black(n).Bold())

04_count_passphrases.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import (
88
. "github.com/logrusorgru/aurora"
99
)
1010

11-
var test1 = `aa bb cc dd aa`
12-
var test2 = `aa bb cc dd aaa`
13-
var test3 = `abcde xyz ecdab`
14-
1511
func main() {
16-
for p := range source.Test(1, test1, `0`).Test(1, test2, `1`).Test(2, test3, `0`).Advent(2017, 4) {
12+
var ins source.Inputs
13+
14+
ins = ins.Test(1, `aa bb cc dd aa`, `0`)
15+
ins = ins.Test(1, `aa bb cc dd aaa`, `1`)
16+
ins = ins.Test(2, `abcde xyz ecdab`, `0`)
17+
18+
for p := range ins.Advent(2017, 4) {
1719
fmt.Println(Brown("\n" + p.Name))
1820
ssw := p.Lines().Words()
1921
fmt.Println(len(ssw), "lines", Black(ssw[0]).Bold())

05_jump_instructions.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ var test1 = `0
1414
-3`
1515

1616
func main() {
17-
for p := range source.Test(1, test1, `5`).Test(2, test1, `10`).Advent(2017, 5) {
17+
var ins source.Inputs
18+
19+
ins = ins.Test(1, test1, `5`)
20+
ins = ins.Test(2, test1, `10`)
21+
22+
for p := range ins.Advent(2017, 5) {
1823
fmt.Println(Brown("\n" + p.Name))
1924

2025
if p.Part(1) {

06_spread_banks.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ import (
1111
var test1 = `0 2 7 0`
1212

1313
func main() {
14-
// source.Dry()
15-
for p := range source.Test(1, test1, `5`).Test(2, test1, `4`).Advent(2017, 6) {
14+
var ins source.Inputs
15+
16+
ins = ins.Test(1, test1, `5`)
17+
ins = ins.Test(2, test1, `4`)
18+
19+
for p := range ins.Advent(2017, 6) {
1620
fmt.Println(Brown("\n" + p.Name))
1721
sn := p.Ints()
1822
fmt.Println(Black(sn).Bold())

07_tree_balance.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ func calc(n *node) int {
4848
}
4949

5050
func main() {
51-
for p := range source.Test(1, test1, `tknk`).Test(2, test1, `60`).Advent(2017, 7) {
51+
var ins source.Inputs
52+
53+
ins = ins.Test(1, test1, `tknk`)
54+
ins = ins.Test(2, test1, `60`)
55+
56+
for p := range ins.Advent(2017, 7) {
5257
fmt.Println(Brown("\n" + p.Name))
5358
ssw := p.Lines().WordsTrim("()->, ")
5459
fmt.Println(len(ssw), Black(ssw[0]).Bold())

08_exec.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ a inc 1 if b < 5
1313
c dec -10 if a >= 1
1414
c inc -20 if c == 10`
1515

16-
// 1 2 4 5 6
17-
18-
var test2 = ``
16+
/*
17+
0 1 2 - 4 5 6
18+
c inc -20 if c == 10`
19+
*/
1920

2021
type regs map[string]int
2122
type comp func(rs regs, r string, v int) bool
@@ -36,7 +37,12 @@ var ops = map[string]op{
3637
}
3738

3839
func main() {
39-
for p := range source.Test(1, test1, `1`).Test(2, test1, `10`).Advent(2017, 8) {
40+
var ins source.Inputs
41+
42+
ins = ins.Test(1, test1, `1`)
43+
ins = ins.Test(2, test1, `10`)
44+
45+
for p := range ins.Advent(2017, 8) {
4046
fmt.Println(Brown("\n" + p.Name))
4147
ssw := p.Lines().Words()
4248
fmt.Println(len(ssw), Black(ssw[0]).Bold())

09_groups_and_garbage.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
. "github.com/logrusorgru/aurora"
88
)
99

10-
var test1 = `{{{<{}>},{},{{}}}}`
10+
func main() {
11+
var ins source.Inputs
1112

12-
var test2 = `<{o"i!a,<{i<a>`
13+
ins = ins.Test(1, `{{{<{}>},{},{{}}}}`, `16`)
14+
ins = ins.Test(2, `<{o"i!a,<{i<a>`, `10`)
1315

14-
func main() {
15-
for p := range source.Test(1, test1, `16`).Test(2, test2, `10`).Advent(2017, 9) {
16+
for p := range ins.Advent(2017, 9) {
1617
fmt.Println(Brown("\n" + p.Name))
1718
s := p.Val
1819
fmt.Println(len(s), Black(s[:14]).Bold())

10_knot_hash.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99
. "github.com/logrusorgru/aurora"
1010
)
1111

12-
var test1 = `3, 4, 1, 5`
13-
1412
func main() {
15-
ins := source.Test(1, test1, `12`)
13+
var ins source.Inputs
14+
15+
ins = ins.Test(1, `3, 4, 1, 5`, `12`)
1616
ins = ins.Test(2, "", `a2582a3a0e66e6e86e3812dcb672a272`)
1717
ins = ins.Test(2, "AoC 2017", "33efeb34ea91902bb2f59c9920caa6cd")
18+
1819
for p := range ins.Advent(2017, 10) {
1920
fmt.Println(Brown("\n" + p.Name))
2021
fmt.Println(Black(p.Val).Bold())

11_hex_grid_distance.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import (
88
. "github.com/logrusorgru/aurora"
99
)
1010

11-
var test1 = `ne,ne,sw,sw`
12-
var test2 = `se,sw,se,sw,sw`
13-
1411
var abs = numbers.Abs
1512

1613
func main() {
17-
// source.Dry()
18-
ins := source.Test(1, test1, `0`)
19-
ins = ins.Test(1, test2, `3`)
14+
var ins source.Inputs
15+
16+
ins = ins.Test(1, `ne,ne,sw,sw`, `0`)
17+
ins = ins.Test(1, `se,sw,se,sw,sw`, `3`)
18+
2019
for par := range ins.Advent(2017, 11) {
2120
fmt.Println(Brown("\n" + par.Name))
2221
sw := par.Lines().Split(",").Values

12_unions.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ var test1 = `0 <-> 2
1616
5 <-> 6
1717
6 <-> 4, 5`
1818

19-
var test2 = ``
20-
2119
func main() {
22-
// source.Dry()
23-
ins := source.Test(1, test1, `6`)
20+
var ins source.Inputs
21+
22+
ins = ins.Test(1, test1, `6`)
2423
ins = ins.Test(2, test1, `2`)
24+
2525
for p := range ins.Advent(2017, 12) {
2626
fmt.Println(Brown("\n" + p.Name))
2727
ssn := p.Lines().Ints()

99_template.go

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func main() {
1414
source.Dry()
1515

1616
var ins source.Inputs
17+
1718
ins = ins.Test(1, test1, `11`)
1819
ins = ins.Test(2, test2, `22`)
1920

lib/source/advent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (ins Inputs) Test(part int, in string, ex ...string) Inputs {
4444
if part&1 == 0 { // test for part 2 only.
4545
ex = append([]string{""}, ex...)
4646
}
47-
return append(ins, Input{Name: "test" + strconv.Itoa(len(ins)), Val: in, parts: part, ex: ex})
47+
return append(ins, Input{Name: "test" + strconv.Itoa(1+len(ins)), Val: in, parts: part, ex: ex})
4848
}
4949

5050
// Advent sources.

0 commit comments

Comments
 (0)