FJIOJ3C4VEBWEJ7KUKQ3EDTAIJ7LADDUGV5JUPJGH5BTH5JOUETAC
XWCHE4XYVQKVUOM6EVX76JSPS6STQZFLIB4ATWALQNU6PDLWK5DQC
P4X7YSA4OK4M6KVUQT4PRMORZVFDETF4MUBOKXNVSTS4M3DXRB2QC
WXM73CW55QMPDEUVONZY3FFHRWJFCU2EBRLL5YGNNRJUSTMZMEYAC
subs []packet
type BITS struct { packets []packet}
type BITS struct {
packets []packet
}
b := parseBITS(st) sum = 0 for _, p := range b.packets { sum += int(p.version) } // log.Println(sum)
b := parseBITS(st)
sum = 0
for _, p := range b.packets {
sum += int(p.version)
// log.Println(sum)
var p packet p.parsePacket(st) sum = sumVersion(p)
var p packet
p.parsePacket(st)
sum = sumVersion(p)
func parseBITS(in string) BITS { b := BITS{} for len(in) >= len("VVVTTTAAAAA") { in = b.parsePacket(in)
func parseBITS(in string) BITS {
b := BITS{}
for len(in) >= len("VVVTTTAAAAA") {
in = b.parsePacket(in)
func sumVersion(p packet) int { var sum int sum += int(p.version) for _, sub := range p.subs { sum += sumVersion(sub)
func sumVersion(p packet) int {
var sum int
for _, sub := range p.subs {
sum += sumVersion(sub)
return b
return sum
func (b *BITS) parsePacket(in string) string {
func (b *packet) parsePacket(in string) string {
p := packet{}
p.version = uint8(temp)
b.version = uint8(temp)
p.typeID = uint8(temp)
b.typeID = uint8(temp)
if p.typeID == 4 { p.number, in = parseLiteral(in[6:])
if p.typeID == 4 {
p.number, in = parseLiteral(in[6:])
if b.typeID == 4 { b.number, in = parseLiteral(in[6:])
if b.typeID == 4 {
b.number, in = parseLiteral(in[6:])
in = b.parseOperator(in[6:])
subp := packet{} in = subp.parseOperator(in[6:]) b.subs = append(b.subs, subp) for len(in) >= len("VVVTTTAAAAA") { var p packet in = p.parsePacket(in) b.subs = append(b.subs, p) }
subp := packet{}
in = subp.parseOperator(in[6:])
b.subs = append(b.subs, subp)
in = p.parsePacket(in)
b.subs = append(b.subs, p)
b.packets = append(b.packets, p)
func (b *BITS) parseOperator(in string) string {
func (b *packet) parseOperator(in string) string {
d, err := parseInput("input.txt")
d, err := parseInput("haver.txt")