mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-18 19:13:27 +02:00
day07 refactor start
This commit is contained in:
@@ -12,3 +12,4 @@ Day | Name | Type of Algo & Notes
|
||||
4 | Secure Container | - May appear math-y, but it's really a string manipulation problem
|
||||
5 | Sunny with a Chance of Asteroids | - Yay more Intcode!........ <br> - This gave me fits... <br> - Good application for recursion (in my opinion)
|
||||
6 | Universal Orbit Map | - __Tree traversal__ and depth calculations. It's not quite a Graph, but it has a __directed graph__ algo feel too
|
||||
7 | Amplification Circuit | - More Intcode... Piping together multiple Intcode computers 😳😳😳
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
3,8,1001,8,10,8,105,1,0,0,21,42,55,64,77,94,175,256,337,418,99999,3,9,102,4,9,9,1001,9,5,9,102,2,9,9,101,3,9,9,4,9,99,3,9,102,2,9,9,101,5,9,9,4,9,99,3,9,1002,9,4,9,4,9,99,3,9,102,4,9,9,101,5,9,9,4,9,99,3,9,102,5,9,9,1001,9,3,9,1002,9,5,9,4,9,99,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,1,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,1,9,4,9,99,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,101,1,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,1001,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,101,1,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,99
|
||||
+14
-15
@@ -2,26 +2,25 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"./intcode"
|
||||
"./permutations"
|
||||
"adventofcode/day07/part1/intcode"
|
||||
"adventofcode/day07/part1/permutations"
|
||||
"adventofcode/util"
|
||||
)
|
||||
|
||||
// input to first amp = 0
|
||||
// output of each amp is input of next amp
|
||||
// final output is from amp #5 / E to thrusters
|
||||
func main() {
|
||||
// input to first amp = 0
|
||||
// output of each amp is input of next amp
|
||||
// final output is from amp #5 / E to thrusters
|
||||
readInput := util.ReadFile("../input.txt")
|
||||
strSplit := strings.Split(readInput, ",")
|
||||
|
||||
input := []int{3, 8, 1001, 8, 10, 8, 105, 1, 0, 0, 21, 42, 55, 64, 77, 94, 175, 256, 337, 418, 99999, 3, 9, 102, 4, 9, 9, 1001, 9, 5, 9, 102, 2, 9, 9, 101, 3, 9, 9, 4, 9, 99, 3, 9, 102, 2, 9, 9, 101, 5, 9, 9, 4, 9, 99, 3, 9, 1002, 9, 4, 9, 4, 9, 99, 3, 9, 102, 4, 9, 9, 101, 5, 9, 9, 4, 9, 99, 3, 9, 102, 5, 9, 9, 1001, 9, 3, 9, 1002, 9, 5, 9, 4, 9, 99, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9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2, 9, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 101, 1, 9, 9, 4, 9, 3, 9, 101, 1, 9, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1001, 9, 1, 9, 4, 9, 99}
|
||||
|
||||
// input := []int{3, 15, 3, 16, 1002, 16, 10, 16, 1, 16, 15, 15, 4, 15, 99, 0, 0}
|
||||
// void return value
|
||||
// phase sequence = 1, initial input = 0
|
||||
// fmt.Println("output of A amp run", intcode.RunDiagnostics(input, 4, 0)) // outputs 3
|
||||
// fmt.Println("output of A amp run", intcode.RunDiagnostics(input, 3, 4)) // outputs 43
|
||||
// fmt.Println("output of A amp run", intcode.RunDiagnostics(input, 2, 43)) // outputs 432...
|
||||
// fmt.Println("output of A amp run", intcode.RunDiagnostics(input, 1, 432)) // outputs 4321
|
||||
// fmt.Println("output of A amp run", intcode.RunDiagnostics(input, 0, 4321)) // outputs 43210
|
||||
input := make([]int, len(strSplit))
|
||||
for i, v := range strSplit {
|
||||
input[i], _ = strconv.Atoi(v)
|
||||
}
|
||||
|
||||
// create all permutations of 0, 1, 2, 3, 4
|
||||
perms := permutations.CreatePermutations()
|
||||
|
||||
Reference in New Issue
Block a user