Keypad Errors
August 2, 2016
[ Programming Praxis passed 2 million lifetime hits over the weekend. Gracious thanks to all my readers who have taken it so far. I can still remember being ecstatic when I got to a thousand hits. Thank you all. — Phil ]
Sometimes one key on a keyboard gets stuck, so some keys that are struck do not register. For instance, you may be trying to type 18684 on a numeric keypad, but if the 8 key is stuck, the keyboard registers you typing 164 instead. Assume the only input allowed is the digits 0 through 9.
Your task is to write a program that takes a target number, say a PIN, and a keyboard input, and determines if the keyboard input matches the target number assuming a single key is stuck. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
One Response to “Keypad Errors”