summaryrefslogtreecommitdiff
path: root/day16.go
blob: 27aa02837af8bb245327230cbf0c1ce34519fd6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"regexp"
)

type Valve struct {
	name string
}

func readValves(f io.Reader) map[string]Valve {
	pattern := regexp.MustCompile(
		`Valve ([A-Z]+) has flow rate=(\d+); tunnels? leads? to valves? ([A-Z, ]+)`,
	)

	s := bufio.NewScanner(f)
	for s.Scan() {
		line := s.Text()
		valveInfo := pattern.FindAllStringSubmatch(line, 3)[0]
		fmt.Println(valveInfo)
	}
	return nil
}

type indexer interface {
    Index() int
}

type proto struct {
    i int
}

func (p proto) Index() int {
    return p.i
}

/*
AA,0 ===================
||.............\\      \\
BB,13===CC,2===DD,20   II,0
...............\\       \\
...............EE,20    JJ,21
...............\\
...............FF,0
...............\\
...............GG,0
...............\\
...............HH,22
Probably can do some apriori thing here
*/
func main() {
	fh, err := os.Open("day16.txt")
	if err != nil {
		log.Fatal("Input file not found")
	}
	valves := readValves(fh)
	fmt.Println(valves)

    p := proto{}
    ps := []proto{p}
    ps[0].i = 100
    fmt.Println(ps)
    ps[0].i = 314
    fmt.Println(ps)
}