All problems
Big Integer Division
Problem
Divide one non-negative integer string by another and return the quotient as a string, truncating any remainder, without converting the whole numbers to integers at once.
Simulate long division digit by digit: bring down the next digit, find how many times the divisor fits by repeated subtraction, and keep the remainder. Assume the divisor is greater than zero.
Hint
The leading zeros in the quotient digits are stripped at the end.
Test cases
case 1
in: ["10","3"]
expected: "3"
case 2
in: ["123456789","123"]
expected: "1003713"
case 3
in: ["999","999"]
expected: "1"
case 4
in: ["0","5"]
expected: "0"
case 5
in: ["7","10"]
expected: "0"
case 6
in: ["1000000000000","2"]
expected: "500000000000"
Starter codePython
def big_divide(a, b):
# Your code here
pass6 test cases · run your code against them in the editor