The characters in the ascii codes have a decimal equivalent: http://www.asciitable.com/. Let's assume the decimal value of each ascii code requires to be 3 digits. So the NUL character is 000. The lower case d character is 100. And so forth. Below is an arithmetic solution to find what the middle digit will be.
(x - (100 * (x / 100))) / 10
For example, if the decimal code is 010, then the formula will work because it gives us 1, which is the middle digit:
(10 - (100 * (10 / 100))) / 10 = 1
Same thing if we plug in another decimal like 100, whose middle digit is 0:
(100 - (100 * (100 / 100))) / 10 = 0
I can easily solve for the solution, but my question is how does the arithmetic work so effectively here in getting us that middle digit? I am quite familiar with the base-10 decimal system, and I can see why we divide by 10 since the middle digit is in the 10's place, but other than that, I'm not sure how this works so effectively.
10 / 100 == 0for your middle statement to actually work out.) – tabstop Feb 10 '14 at 23:56