Zwischenstand
This commit is contained in:
parent
233513758a
commit
dde902d2b4
@ -12,19 +12,13 @@ func main() {
|
|||||||
result := 0
|
result := 0
|
||||||
index := 1
|
index := 1
|
||||||
for i := 0; i < len(lines); i += 3 {
|
for i := 0; i < len(lines); i += 3 {
|
||||||
//fmt.Println(lines[i])
|
fmt.Println(lines[i])
|
||||||
//fmt.Println(lines[i+1])
|
fmt.Println(lines[i+1])
|
||||||
//fmt.Println(comparePair(lines[i], lines[i+1]))
|
fmt.Println(comparePair(lines[i], lines[i+1]))
|
||||||
//fmt.Println()
|
fmt.Println()
|
||||||
if comparePair(lines[i], lines[i+1]) == 0 {
|
if comparePair(lines[i], lines[i+1]) == 0 {
|
||||||
result += index
|
result += index
|
||||||
}
|
}
|
||||||
if comparePair(lines[i], lines[i+1]) == -2 {
|
|
||||||
fmt.Println(lines[i])
|
|
||||||
fmt.Println(lines[i+1])
|
|
||||||
fmt.Println(comparePair(lines[i], lines[i+1]))
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
|
|
||||||
index++
|
index++
|
||||||
}
|
}
|
||||||
@ -36,8 +30,8 @@ func main() {
|
|||||||
//-1 Left Value to high
|
//-1 Left Value to high
|
||||||
//-2 Right had no values left
|
//-2 Right had no values left
|
||||||
func comparePair(left string, right string) int {
|
func comparePair(left string, right string) int {
|
||||||
lefIndex := -1
|
lefIndex := 0
|
||||||
rightIndex := -1
|
rightIndex := 0
|
||||||
currentElemLeft := 0
|
currentElemLeft := 0
|
||||||
currentElemRight := 0
|
currentElemRight := 0
|
||||||
leftElementType := 0
|
leftElementType := 0
|
||||||
@ -58,7 +52,7 @@ func comparePair(left string, right string) int {
|
|||||||
if rightElementType == 0 {
|
if rightElementType == 0 {
|
||||||
for leftElementType != 0 {
|
for leftElementType != 0 {
|
||||||
lefIndex, leftElementType = getNextElement(left, lefIndex)
|
lefIndex, leftElementType = getNextElement(left, lefIndex)
|
||||||
if leftElementType == -1 {
|
if leftElementType == -1 || leftElementType == -3 {
|
||||||
return -2
|
return -2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,6 +86,7 @@ func comparePair(left string, right string) int {
|
|||||||
//-1 End Packet
|
//-1 End Packet
|
||||||
//-2 Start Array
|
//-2 Start Array
|
||||||
//-3 End Array
|
//-3 End Array
|
||||||
|
//-4 Seperator
|
||||||
func getNextElement(packet string, currentIndex int) (int, int) {
|
func getNextElement(packet string, currentIndex int) (int, int) {
|
||||||
index := currentIndex + 1
|
index := currentIndex + 1
|
||||||
for index < len(packet) {
|
for index < len(packet) {
|
||||||
|
8
day13/testinput2
Normal file
8
day13/testinput2
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[1,2]
|
||||||
|
[[],2,3]
|
||||||
|
|
||||||
|
[[],[8,[[5,10,5]],9]]
|
||||||
|
[[[[2,8,4],[2,0],4,6,4],2,[[10,5,10],1,[10,9,1,1]]],[2,7],[],[[[3,1,4,8,4],4,[0,5,9,3],4,[]],[],[8,2]]]
|
||||||
|
|
||||||
|
[[[],2],[0,6,[[2,7,7,2,4],[7,1]],6,2]]
|
||||||
|
[[3,[],[[10,2,1,5]]],[]]
|
Loading…
Reference in New Issue
Block a user