@@ -0,0 +1,1032 @@
+#!/usr/local/bin/python%0A# Code Fights Pages Numbering With Ink Problem%0A%0Aimport math%0A%0A%0Adef pagesNumberingWithInk(current, numberOfDigits):%0A    num = current%0A    digits = (int(math.log(num, 10)) + 1)%0A    available = numberOfDigits - digits%0A    while available %3E= digits:%0A        digits = int(math.log(num + 1, 10)) + 1%0A        if digits %3C= available:%0A            num += 1%0A            available -= digits%0A        else:%0A            return num%0A%0A    return num%0A%0A%0Adef main():%0A    tests = %5B%0A        %5B1, 5, 5%5D,%0A        %5B21, 5, 22%5D,%0A        %5B8, 4, 10%5D,%0A        %5B21, 6, 23%5D,%0A        %5B76, 250, 166%5D,%0A        %5B80, 1000, 419%5D%0A    %5D%0A%0A    for t in tests:%0A        res = pagesNumberingWithInk(t%5B0%5D, t%5B1%5D)%0A        ans = t%5B2%5D%0A        if ans == res:%0A            print(%22PASSED: pagesNumberingWithInk(%7B%7D, %7B%7D) returned %7B%7D%22%0A                  .format(t%5B0%5D, t%5B1%5D, res))%0A        else:%0A            print((%22FAILED: pagesNumberingWithInk(%7B%7D, %7B%7D) returned %7B%7D,%22%0A                   %22answer: %7B%7D%22).format(t%5B0%5D, t%5B1%5D, res, ans))%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Solve Code Fights pages numbering with ink problem