The problem is https://leetcode.com/problems/binary-watch/.
Because the input size is limited, generating every output is workable.
Simplely follow the input, using itertools
could generate all combinations.
import itertools
digitals = [8, 4, 2, 1, 32, 16, 8, 4, 2, 1]
def get_xtime(ps):
h = 0
m = 0
for ...