Like the title says:
from itertools import permutations def number_of_clicks(l): bets = list(l) clicks = 0 state = [[False, None], [False, None], [False, None], [False, None], [False, None]] while bets: next = bets.pop(0) for s, n in zip(state, next): if s[0] != n[0]: clicks += 1 # checkbox s[0] = n[0] if s[1] != n[1] and n[1] is not None: clicks += 2 # dropdown s[1] = n[1] return clicks bets = map(lambda l: map(lambda p: [bool(p), p], l), input()) result = min(permutations(bets), key=number_of_clicks) for l in result: print map(lambda e: e[1], l) print number_of_clicks(result) (taken from this Sandbox post)
<!-- language: lang-python --> Has no effect.
Syntax highlighting would be very useful for the Sandbox. It works on Meta.SO, so why not here?