I'm searching for a way to count unique digits efficiently with a one liner.
For example: given the integer 623562
, return value would be 4
.
My current way of doing it is, given integer i
, im using len(set(str(i)))
.
Creating a set is time consuming. I'm going over alot of numbers so I need an efficient way.
Also, if someone can find a way to go over all the numbers with x
digits without using
range()
(and in a one liner..), I'll be glad. Memory limits me when using range
because a list is created (I assume).