You will be given an ASCII text. This text may have zero, one or many appearances of a split a character (let's assume it will be the space character )
You will also be given an offset integer value (zero based) anywhere between zero and the length of the text.
You should calculate the relative offset inside the one split text, which contains the absolute offset, as well as the index of that very split text.
If the given offset is at the split character the last split should have the offset
It's hard to describe (comments welcome), so here are some examples
text: Lorem ipsum dolor sit amet
offset: 20
Lorem ipsum dolor sit amet
enter code here
--------------------^
000000000011111111112
012345678901234567890
Result: 2, 3
Explanation: If we split the text along the space characters, the split text, where the offset is in, is the fragment `sit` which is the 3rd split (count starts at zero) and the offset inside this fragment is 2
sit
--^
012
Some more examples
Text Offset Result
Lorem ipsum dolor sit amet 0 0, 0
^
Lorem ipsum dolor sit amet 1 1, 0
-^
Lorem ipsum dolor sit amet 2 2, 0
--^
Lorem ipsum dolor sit amet 3 3, 0
---^
Lorem ipsum dolor sit amet 4 4, 0
----^
Lorem ipsum dolor sit amet 5 5, 0
-----^
Lorem ipsum dolor sit amet 6 0, 1
------^
Lorem ipsum dolor sit amet 7 1, 1
-------^
Lorem ipsum dolor sit amet 8 2, 1
--------^
Lorem ipsum dolor sit amet 9 3, 1
---------^
Lorem ipsum dolor sit amet 10 4, 1
----------^
Lorem ipsum dolor sit amet 11 5, 1
-----------^
Lorem ipsum dolor sit amet 12 0, 2
------------^
Lorem ipsum dolor sit amet 13 1, 2
-------------^
Lorem ipsum dolor sit amet 14 2, 2
--------------^
Lorem ipsum dolor sit amet 15 3, 2
---------------^
Lorem ipsum dolor sit amet 16 4, 2
----------------^
Lorem ipsum dolor sit amet 17 5, 2
-----------------^
Lorem ipsum dolor sit amet 18 0, 3
------------------^
Lorem ipsum dolor sit amet 19 1, 3
-------------------^
Lorem ipsum dolor sit amet 20 2, 3
--------------------^
Lorem ipsum dolor sit amet 21 3, 3
---------------------^
Lorem ipsum dolor sit amet 22 0, 4
----------------------^
Lorem ipsum dolor sit amet 23 1, 4
-----------------------^
Lorem ipsum dolor sit amet 24 2, 4
------------------------^
Lorem ipsum dolor sit amet 25 3, 4
-------------------------^
Lorem ipsum dolor sit amet 26 4, 4
--------------------------^
offset
characters, the first is the character that is hit inside the chunk counted from its own origin? Do the two have anything in common? \$\endgroup\$Do the two have anything in common?
? \$\endgroup\$