projects > other > advent_of_code.go
1
Advent of Code 2024[github]
1
2
Advent of Code is an Advent calendar of small programming puzzles
3
for a variety of skill levels that can be solved in any
4
programming language you like. People use them as interview prep,
5
company training, university coursework, practice problems, a
6
speed contest, or to challenge each other.
7
8
You don't need a computer science background to participate -
9
just a little programming knowledge and some problem solving
10
skills will get you pretty far. Nor do you need a fancy computer;
11
every problem has a solution that completes in at most 15 seconds
12
on ten-year-old hardware.
13
14
[Go][GitHub]
15
17
18
func Part2(input []byte) {
19
line := strings.Trim(string(input), "\n")
20
stones := parse(line)
21
blinks := 75
22
23
cache := map[Pair]uint64{}
24
count := big.NewInt(0)
25
for _, stone := range stones {
26
count.Add(count, new(big.Int).SetUint64(walk(uint64(stone), uint64(blinks), cache)))
27
}
28
29
fmt.Println("Result is", count)
30
}
31
32
type Pair struct {
33
f uint64
34
s uint64
35
}
36
37
func walk(it, deepth uint64, cache map[Pair]uint64) uint64 {
38
if deepth == 0 {
39
return 1
40
}
41
42
cached, exists := cache[Pair{it, deepth}]
43
if exists {
44
return cached
45
}
46
47
NORMAL~/oleksandr/projects/other/advent_of_code.go.../other/advent_of_code.gomainutf-8
Enter to open · :q to quit
keys
j / kmove the cursor line, or the tree cursor
hfocus the tree; in the tree, fold or go to the parent
l / Enterin the tree, unfold or open the file
gg / Gfirst / last line
clickput the cursor on a line; on README.sh, run the session again
:qquit to the shell
:help ?this table
q / Escclose this