Skip to content

Commit

Permalink
generic updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dbut2 committed Dec 1, 2023
1 parent d7d77a7 commit c870c62
Show file tree
Hide file tree
Showing 16 changed files with 498 additions and 132 deletions.
33 changes: 33 additions & 0 deletions 2019/01/01.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"embed"
_ "embed"
"fmt"

"github.com/dbut2/advent-of-code/pkg/sti"
"github.com/dbut2/advent-of-code/pkg/utils"
)

//go:embed input.txt
var input string

//go:embed test*.txt
var tests embed.FS

func main() {
fmt.Println(solve(input))
}

func solve(input string) int {
s := utils.ParseInput(input)

total := 0

for _, line := range sti.Stis(s) {
lv := (line / 3) - 2
total += lv
}

return total
}
40 changes: 40 additions & 0 deletions 2019/01/02.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"embed"
_ "embed"
"fmt"

"github.com/dbut2/advent-of-code/pkg/sti"
"github.com/dbut2/advent-of-code/pkg/utils"
)

//go:embed input.txt
var input string

//go:embed test*.txt
var tests embed.FS

func main() {
fmt.Println(solve(input))
}

func solve(input string) int {
s := utils.ParseInput(input)

total := 0

for _, line := range sti.Stis(s) {
mass := line
for {
f := mass/3 - 2
if f < 0 {
break
}
total += f
mass = f
}
}

return total
}
100 changes: 100 additions & 0 deletions 2019/01/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
141107
119016
145241
72264
116665
81420
88513
128809
145471
81570
124798
75370
84988
71634
135275
96992
53376
62414
148277
135418
82475
137707
105051
83450
102673
88390
100849
94528
135709
63945
126413
70107
84734
119176
85769
115276
137511
61806
92892
121640
93726
146526
95812
132556
103885
78776
55826
120257
61131
79179
130698
97153
121985
61159
103585
148674
84067
110085
138473
105495
112393
144411
73328
125955
58075
136147
124106
81185
138847
69814
127104
86090
67666
102333
99546
98280
99062
129433
125353
77609
71240
71791
146046
113685
121381
122715
147789
53981
140926
81528
121789
106627
73745
67509
144140
119238
82417
129215
75663
106842
Empty file added 2019/01/test1.txt
Empty file.
Empty file added 2019/01/test2.txt
Empty file.
1 change: 1 addition & 0 deletions 2022/01/01.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?=max(array_map(fn($s)=>array_sum(explode("\n",$s)),explode("\n\n",file_get_contents('input.txt'))));
5 changes: 5 additions & 0 deletions 2022/12/02v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"fmt"
"strings"
"sync"
"time"

"github.com/dbut2/advent-of-code/pkg/benchmark"
"github.com/dbut2/advent-of-code/pkg/test"
)

Expand All @@ -20,6 +22,9 @@ func main() {
t := test.Register(tests, solve)
t.Expect(1, 29)
fmt.Println(solve(input))
benchmark.Run(func() {
solve(input)
}, benchmark.Time(time.Second*10))
}

func solve(input string) int {
Expand Down
2 changes: 1 addition & 1 deletion 2022/13/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,4 @@
[[[3,[],5],[5,[10,1,1,4]],[[7,3],[10,10,1,9,7],1,1],[5,[6,8,0,2]]],[[6,[0,7]],6,[10,[5,1]]],[],[],[[],[]]]

[[9,5,8,7,[[9]]],[0,10,[6,10,[3,9,7,8]],[],3]]
[[7,7,[9,[9],[10,5,4,4,2],5]],[5,6,[10,8,0,[8,1,6,9],[1,1]]],[],[[],[1,4,[7,7,0]],[[9,7,1],[5,8,2,1],2,[4,7,7,6],2],[[9,1,6,10]],10]]
[[7,7,[9,[9],[10,5,4,4,2],5]],[5,6,[10,8,0,[8,1,6,9],[1,1]]],[],[[],[1,4,[7,7,0]],[[9,7,1],[5,8,2,1],2,[4,7,7,6],2],[[9,1,6,10]],10]]
Loading

0 comments on commit c870c62

Please sign in to comment.