map = ['0', '1', '2', '3']
perms = []

def multisetPerms(s, result):
    if all(v is 0 for v in s):
        perms.append(result)
return
for i in range(len(s)):
    if s[i] > 0:
        _s = s[:]
_s[i] = _s[i] - 1
multisetPerms(_s, result + map[i])
multisetPerms([3, 2, 4], '')
print((len(perms), perms[0:10]))
Python long permutations with repeated characters