@@ -0,0 +1,430 @@
+# Time:  O(P), P is the smallest power of 10 greater than N%0A# Space: O(1)%0A%0Adef counting_sheep():%0A    N = int(input())%0A    if N == 0:%0A        return %22INSOMNIA%22%0A%0A    digits = set(%5B%5D)%0A    cnt = 0%0A    while len(digits) != 10:%0A        cnt += N%0A        tmp = cnt%0A        while tmp:%0A            digits.add(tmp %25 10)%0A            tmp /= 10%0A    return cnt%0A%0Afor case in xrange(input()):%0A    print 'Case #%25d: %25s' %25 (case+1, counting_sheep())%0A

Create counting_sheep.py