Holy numbers are numbers composed of only the digits with holes, which are:
Numbers with at least one unholy digit are considered unholy. Unholy digits are evil by definition, but being close to holy digits help them become neutral. Hence, the closer they are, the less unholy (1 when adjacent).
The unholiness of a number is the sum of the unholyness of its digits, a number composed of only unholy number has an infinite unholiness.
Number :8 5 5 8 7 Digital Unholiness:0+1+1+0+1 Total Unholiness :3 Number :0 1 7 5 5 2 8 5 7 Digital Unholiness:0+1+2+3+2+1+0+1+2 Total Unholiness :12 Number :1 5 7 3 2 1 Digital Unholiness:∞+∞+∞+∞+∞+∞ Total Unholiness :∞ Number :0 4 6 8 9 Digital Unholiness:0+0+0+0+0 Total Unholiness :0
You have to write a program or function that takes a positive integer or a string only composed of digits as input, and output its unholiness. If you chose to use an integer as input, you can assume it will never have a leading
0 as your language may drop it.
In case of infinite unholiness, you can chose between three outputs
- The character
- Infinite output containing at least 1 non-zero digit, but only digits.
- A built-in
This is code-golf, so the shortest code in byte wins, good luck!