How to optimize python snippet? :     def nonrep1(n):
        return sum(all(c != d for c, d in zip(str(i), str(i)[1:])) for i in xrange(1, n+1))

I have to optimize this code, how do I do that??

     test case 1

simple input 

    7

simple output

    7





test case 2

simple input 

    3456

simple output

    2562





