(self, x, y)
| 153 | return answer |
| 154 | |
| 155 | def check_division(self, x, y): |
| 156 | eq = self.assertEqual |
| 157 | with self.subTest(x=x, y=y): |
| 158 | q, r = divmod(x, y) |
| 159 | q2, r2 = x//y, x%y |
| 160 | pab, pba = x*y, y*x |
| 161 | eq(pab, pba, "multiplication does not commute") |
| 162 | eq(q, q2, "divmod returns different quotient than /") |
| 163 | eq(r, r2, "divmod returns different mod than %") |
| 164 | eq(x, q*y + r, "x != q*y + r after divmod") |
| 165 | if y > 0: |
| 166 | self.assertTrue(0 <= r < y, "bad mod from divmod") |
| 167 | else: |
| 168 | self.assertTrue(y < r <= 0, "bad mod from divmod") |
| 169 | |
| 170 | def test_division(self): |
| 171 | digits = list(range(1, MAXDIGITS+1)) + list(range(KARATSUBA_CUTOFF, |
no test coverage detected