incomplete day17
This commit is contained in:
parent
b1a6912dd8
commit
7ef83667ac
40
day17/day.go
Normal file
40
day17/day.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package day17
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"tools"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getCombinations(containers []int, sum int) (combinations [][]int) {
|
||||||
|
for i, c := range containers {
|
||||||
|
if c > sum {
|
||||||
|
break
|
||||||
|
} else if c == sum {
|
||||||
|
return [][]int{{c}}
|
||||||
|
} else if i == len(containers)-1 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
subCombinations := getCombinations(containers[i:], sum-c)
|
||||||
|
for _, v := range subCombinations {
|
||||||
|
subCombination := append([]int{c}, v...)
|
||||||
|
combinations = append(combinations, subCombination)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return combinations
|
||||||
|
}
|
||||||
|
|
||||||
|
func Part1(puzzle tools.AoCPuzzle) interface{} {
|
||||||
|
input := puzzle.GetInputArrayInt()
|
||||||
|
sort.Ints(input)
|
||||||
|
|
||||||
|
combos25 := getCombinations(input, 25)
|
||||||
|
fmt.Println(combos25)
|
||||||
|
//combos150 := getCombinations(input, 150)
|
||||||
|
|
||||||
|
return len(combos25)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Part2(puzzle tools.AoCPuzzle) interface{} {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
20
inputs/17
Normal file
20
inputs/17
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
33
|
||||||
|
14
|
||||||
|
18
|
||||||
|
20
|
||||||
|
45
|
||||||
|
35
|
||||||
|
16
|
||||||
|
35
|
||||||
|
1
|
||||||
|
13
|
||||||
|
18
|
||||||
|
13
|
||||||
|
50
|
||||||
|
44
|
||||||
|
48
|
||||||
|
6
|
||||||
|
24
|
||||||
|
41
|
||||||
|
30
|
||||||
|
42
|
||||||
5
inputs/17_test
Normal file
5
inputs/17_test
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
20
|
||||||
|
15
|
||||||
|
10
|
||||||
|
5
|
||||||
|
5
|
||||||
2
main.go
2
main.go
@ -17,6 +17,7 @@ import (
|
|||||||
"aoc2015/day14"
|
"aoc2015/day14"
|
||||||
"aoc2015/day15"
|
"aoc2015/day15"
|
||||||
"aoc2015/day16"
|
"aoc2015/day16"
|
||||||
|
"aoc2015/day17"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
@ -50,6 +51,7 @@ func initDayFunctions() {
|
|||||||
14: {1: day14.Part1, 2: day14.Part2},
|
14: {1: day14.Part1, 2: day14.Part2},
|
||||||
15: {1: day15.Part1, 2: day15.Part2},
|
15: {1: day15.Part1, 2: day15.Part2},
|
||||||
16: {1: day16.Part1, 2: day16.Part2},
|
16: {1: day16.Part1, 2: day16.Part2},
|
||||||
|
17: {1: day17.Part1, 2: day17.Part2},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user