day20, modules state comparations

This commit is contained in:
efim
2023-12-20 09:58:40 +00:00
parent 00e60657fa
commit f538945dff
3 changed files with 51 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ func Run() int {
filename := "day20/example2"
modules := ReadModules(filename)
InitStuffs(modules)
log.Print("got modules:\n", modules)
low, high := PropagateButtonPress(modules)
@@ -97,3 +98,14 @@ func InitStuffs(allModules map[string]Module) {
}
}
func ModulesState(allModules map[string]Module) string {
// relying on printing of map values to be ordered by key
// https://stackoverflow.com/a/54524991/2788805
states := make(map[string]string)
for name, module := range allModules {
states[name] = module.StateSnapshot()
}
return fmt.Sprint(states)
}