If we are only allowed to look at the lights, then the minimal number of visits is:
5
Proof by code:
import collections
import itertools
matchings = [(p, (0,) * 6) for p in itertools.permutations(range(6))]
#by symmetry, on first pull we only care about number pulled
pull_sets0 = [(1,) * k + (0,) * (6 - k) for k in range(1,4)]
#only makes sense to pull 3 or fewer switches in 1 go
pull_sets = [x for x in itertools.product(range(2), repeat=6) if sum(x) <= 3]
def go(matchings, bound):
if len(matchings) == 1:
return 1
if bound == 0:
return 0
for pull_set in (pull_sets0 if len(matchings) == 720 else pull_sets):
new_matchings = []
for m, s in matchings:
s = list(s)
for i, j in enumerate(m):
if pull_set[i]:
s[j] ^= 1
new_matchings.append((m, tuple(s)))
match_groups_1 = collections.defaultdict(lambda: [])
match_groups_2 = collections.defaultdict(lambda: [])
for m, s in new_matchings:
match_groups_1[s[:3]].append((m, s))
match_groups_2[s[3:]].append((m, s))
if len(matchings) == 720:
match_groups_2 = {}
for match_groups in (match_groups_1, match_groups_2):
if len(match_groups) > 1:
if all(go(ms, bound - 1) for ms in match_groups.values()):
return 1
return 0
for bound in itertools.count(1):
print(f"trying {bound}...")
if go(matchings, bound):
break
print("success!!")