@@ -0,0 +1,855 @@
+#!/usr/local/bin/python%0A# Code Fights Count Black Cells Problem%0A%0Afrom fractions import gcd%0A%0A%0Adef countBlackCells(m, n):%0A    # Manhattan distance plus lattice points less 2 end points%0A    return (m + n) + gcd(n, m) - 2%0A%0A%0Adef main():%0A    tests = %5B%0A        %5B3, 4, 6%5D,%0A        %5B3, 3, 7%5D,%0A        %5B2, 5, 6%5D,%0A        %5B1, 1, 1%5D,%0A        %5B1, 2, 2%5D,%0A        %5B1, 3, 3%5D,%0A        %5B1, 239, 239%5D,%0A        %5B33, 44, 86%5D,%0A        %5B16, 8, 30%5D,%0A        %5B66666, 88888, 177774%5D%0A    %5D%0A%0A    for t in tests:%0A        res = countBlackCells(t%5B0%5D, t%5B1%5D)%0A        ans = t%5B2%5D%0A        if ans == res:%0A            print(%22PASSED: countBlackCells(%7B%7D, %7B%7D) returned %7B%7D%22%0A                  .format(t%5B0%5D, t%5B1%5D, res))%0A        else:%0A            print(%22FAILED: countBlackCells(%7B%7D, %7B%7D) returned %7B%7D, answer: %7B%7D%22%0A                  .format(t%5B0%5D, t%5B1%5D, res, ans))%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Solve Code Fights count black cells problem