Coding Short: Mental Division Trainer

Theodore Yoong
3 min readFeb 1, 2019

--

A huge thank you to K.S. and M.C. for making this possible!

If you walk past my room in the middle of the night, you might hear ominous chanting emanating from within. Don’t call the police — I’m not a lunatic performing some crazy ritual to summon subterranean pixies, I’m just practicing my mental division!

For those who’ve read my previous article, you would know that I’ve been preparing for prop trading interviews. One of the most prized skills is mental maths. Most notably, Optiver and Flow Traders have mental maths tests to screen out a large portion of their applicant pool.

Resources

Unfortunately, as tradertest.com is no longer functional, a great place to check your speed and practice your mental arithmetic is rankyourbrain.com. If this seems tough at first, don’t worry — practice makes perfect!

As for picking up tips and tricks to accelerate your mental arithmetic, Arthur Benjamin and Michael Shermer also wrote a really helpful book that I’ve used since first year.

Python Script

Of all the mental maths tricks that I’ve picked up from the book, mental division has been the biggest obstacle for me, especially with two-digit divisors. I was really uncomfortable doing timed division questions, so here’s a simple script that feeds me untimed division questions. The Python code is given below:

import randomdef generate_question():
number1, number2 = random.randint(1, 99), random.randint(1, 99)
return (number1*number2, number2)
dividend, divisor = generate_question()
answer = dividend/divisor
while True:
guess = input("{}/{}: ".format(dividend, divisor))
if guess == 'Quit':
break
while not(guess.isdigit() and int(guess) == answer):
guess = input("Try again: ")
print("Correct!\n")
dividend, divisor = generate_question()
answer = dividend/divisor

As the book focuses on problems with non-zero remainders, which takes a lot more time to think, I felt that the method of targeting problems with integer quotients can be further simplified. Here are a couple of examples to illustrate my thought process whenever I come across such a problem.

1. 3071/37 = ?

I prefer solving these from left-to-right, i.e. figuring out the tens digit first. 37 is close to 40, 40x8=320, and 40x7=280. This means that 40x80=3200 and 40x70=2800, and we expect the tens digit to be either 7 or 8. We can whittle down to a single choice too — 37x8=240+56=296 (work it out from left-to-right), so 37x80=2960. Since 3071>2960, the tens digit has to be 8.

As for the units digit, we are blessed with an odd divisor, which means there is a one-to-one mapping from the units digit in the divisor to the units digit in the dividend! Let’s recap our times-tables:

7x1=7 -> Units digit 7
7x2=14 -> Units digit 4
7x3=21 -> Units digit 1
7x4=28 -> Units digit 8
7x5=35 -> Units digit 5
7x6=42 -> Units digit 2
7x7=49 -> Units digit 9
7x8=56 -> Units digit 6
7x9=63 -> Units digit 3

The units digit of our dividend is 1, while the units digit of our divisor is 7. This means the units digit of our quotient has to be 3! Indeed, 3071/37=83.

2. 2736/76 = ?

For the tens digit, we can reapply the same logic. As 70x40=2800, we expect the tens digit to be 3.

However, as our divisor is now even, the mapping is now two-to-one. In this case, we know that the units digit of our quotient is either 1 or 6. The best way to think of this is through estimates. 76x3=210+18=228, so 76x30=2280. 76x31 is too low, and we can conclude our units digit is 6. Once again, it is easy to verify that 2736/76=36.

This sums up my coding short! Feel free to leave any feedback or interesting examples.

--

--