Based on this Numberphile video
A self-locating string is a number (or set of numbers) in a decimal expansion which corresponds to its location, from the start of the decimal.
For example, take the number:
Here, we can identify certain items quickly, e.g:
.27 _3_ _4_ 1263 _9_ 3112
There are a few more complex cases in here though, too. For instance, the numbers
12 both appear starting in their respective positions:
.2734126393112 123456789ABCD ^ 11 ^ 12
So the list of self-locating strings in this case would be
[3, 4, 9, 11, 12], as even though some of them overlap, they both start in the correct places. If we sum these up, we get 39, or the self-reference index (SRI) of this terminating decimal.
A terminating decimal, either an array of digits (after the point) or a decimal type with
0. at the start/
The SRI of the input number.
- In the case that there are no self-referential numbers, the SRI is 0. This must be returned/printed, as opposed to exiting or returning undefined.
- The decimal expansion can be assumed to terminate, and will be no more than 128 digits in length.
- The counting of the indexes should be 1-based, e.g the first decimal is at position
- Standard I/O rules + standard loopholes apply.
- This is code-golf, so shortest answer in bytes wins
0.1207641728 -> 3 .12345678910 -> 55 0.1234567890112 -> 68 .0 -> 0 0.654321 -> 0 .54321 -> 3