day20, small cleanup
This commit is contained in:
@@ -11,15 +11,15 @@ func Run() int {
|
||||
// fmt.Println("hello from dya 20")
|
||||
|
||||
filename := "day20/input"
|
||||
modules := ReadModules(filename)
|
||||
InitStuffs(modules)
|
||||
// modules := ReadModules(filename)
|
||||
// InitStuffs(modules)
|
||||
// log.Print("got modules:\n", modules)
|
||||
|
||||
// var low, high int
|
||||
// low, high = Count10000ButtonPresses(modules)
|
||||
// log.Printf("got low %d and high %d\n", low, high)
|
||||
|
||||
CheckSubgraphsStuff(modules)
|
||||
CheckSubgraphsStuff(filename)
|
||||
|
||||
var result int
|
||||
// result = CalcCommonStep()
|
||||
@@ -27,25 +27,33 @@ func Run() int {
|
||||
return result
|
||||
}
|
||||
|
||||
func CheckSubgraphsStuff(allModules map[string]Module) {
|
||||
func CheckSubgraphsStuff(filename string) {
|
||||
// loopStarts := allModules["broadcast"].Outputs()
|
||||
|
||||
// loop start and loop sink
|
||||
loopItems := map[string]string {
|
||||
// "sr": "xn",
|
||||
// "ch": "xf",
|
||||
// "hd": "qn",
|
||||
"sr": "xn",
|
||||
"ch": "xf",
|
||||
"hd": "qn",
|
||||
"bx": "zl",
|
||||
}
|
||||
|
||||
for start, end := range loopItems {
|
||||
allModules := ReadModules(filename)
|
||||
InitStuffs(allModules)
|
||||
|
||||
log.Printf(">>> searching for loop of %s", start)
|
||||
themap := make(map[string]any)
|
||||
loopModules := TransitiveOutputs(start, allModules, themap)
|
||||
// i think my bug is not to reset state of `allModules`
|
||||
_, _, requestedPulses := FindSubGraphLoopLength(loopModules, allModules, end)
|
||||
FilterMonitoredPulses(requestedPulses)
|
||||
log.Printf("the pulses: +%v", requestedPulses)
|
||||
}
|
||||
|
||||
// yeah. and now all cycles start from 1 (first button press)
|
||||
// and then they emit the [high low] on last step of their cycle
|
||||
// so just LCM of these all
|
||||
}
|
||||
|
||||
func Count10000ButtonPresses(modules map[string]Module) (lowSignalsCount, highSignalsCount int) {
|
||||
|
||||
Reference in New Issue
Block a user