package main type PathFilter struct { initial PathFilterState } func (filter PathFilter) exec(state *ProgramState) bool { pathFilterState := make(map[PathFilterState]struct{}) pathFilterState[filter.initial] = struct{}{} for _, segment := range state.space.path { nextPathFilterState := make(map[PathFilterState]struct{}) for curState := range pathFilterState { for nextState := range curState.eat(segment) { nextPathFilterState[nextState] = struct{}{} } } pathFilterState = nextPathFilterState } for pathState := range pathFilterState { if pathState.accept() { return true } } return false } type RangeFilter struct { start Filter end Filter active bool } type Filter interface { exec(*ProgramState) bool }