The information panels are everywhere. When the technology became cheaper, the paper posters were transformed into luminous signs that show words that appear on one side and come out on the other, like the one on the figure:
When one of these signs starts up, it usually starts empty and the text leaves from the right side to the left, moving until it disappears.
Its functionality is to go on and off the small light bulbs (LEDs) to give the sensation of movement.
If instead of text we only need to show numbers, the poster can be much less sophisticated using the so-called seven-segment markers like the following:
In this case each number is represented by the combination on / off of only 7 light segments that allow to represent all the numbers:
The question we ask ourselves is how many changes of lights (how many on and off) should be made to pass through one of these posters a certain number?
For example, to show the 123 in a 3-digit sign that starts with all the LEDs off we will have:
This makes a total of 42 changes of lights.
Given a non-negative number and a positive sign length calculate the number of lights changes.
- Assume input consist in a non-negative number (N >= 0) and a positive sign length (M > 0)
- Assume Sign length >= Number length (M >= digits(N))
123, 3 => 42 45, 5 => 60 111, 3 => 12 98765, 10 => 220 0, 3 => 36