day20, modules state comparations
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user