in Technology

LB: Faulty Calculator

Your dad found out a calculator that he used while he was in college. It’s still in good shape but a few keys are not working properly. You really like the calculator – it’s unique, runs on solar power and works overall. You also figured out how to solve some of the idiosyncrasies of the machine.

  • The 5 digit comes only if you press the 5 key twice.
  • If the immediate number after 5 is 2, 5 works on single key press, but 2 requires two presses.
  • If you do not press any other key after 1, it keeps taking 1 as input (so 11111111…)
  • If the result of the last calculation had 2 and 3 in it, you have to press the Clear button twice to actually clear it

You are comfortable using the calculator now, but you now want to build a simple software that mimics your calculator. More importantly, you want your younger sis to use the software as well. Catch is that she does not know the “bugs” in the calculator that we talked about earlier. So when she is using it, you want to convert her input in a format that your calculator can understand. And then take the result from the calculator and show it to her in a way that she can understand.

Ready for the challenge? Then go ahead and code it up!


What are Logic Builders?
Logic Builders are puzzles that you solve using a programming language of your choice. The idea is to improve the logical and programming abilities by solving a fun problem. The puzzles also require use of some data structures so your skills in effective data management also improve. And of course, you have to code for boundary conditions to pass 😉

Write a Comment

Comment