Problem 42323. With apologies to William Blake

 Coder Coder, typing fast
 Sitting at your desk, aghast.
 What immortal MATLAB script
 will solve this problem, nice and quick?

You are given a number. Your task is to write a MATLAB script that will calculate the smallest positive number you need to add to your original number so that each digit in your sum will have horizontal symmetry. For this problem, those numbers are [0 1 3 8]

For example:

  • If you are given 27, your script should output 3, as 27+3=30. Both 3 and 0 have horizontal symmetry.
  • If you are given 801, your script should output 0, as 801+0=801. 8, 0 and 1 are all horizontally symmetric.
  • If you are given 900, your answer should be 100, as 900+100=1000, which is the next highest number that is horizontally symmetric.

Good luck. May you become a poet, and not even know it.

Solution Stats

27.78% Correct | 72.22% Incorrect
Last Solution submitted on Jul 06, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers68

Suggested Problems

More from this Author80

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!