Given a non negative integer number tell if it can be erased by repeatedly removing all occurrences of the length of that number from it including overlapping matches.
- Erasing means cancel all its digits.
For example the number 4440 is not lengthy because after removing all 4's you obtain 0 which cannot be erased.
Neither the number 50022 or 50044 is lengthy A because you first remove 5 obtaining 0022 or 0044 and there's no way to cancel leading 0's.
Examples
3610106336 has 10 digits: remove 10's 36xxXX6336 -> 366336 366336 has 6 digits: remove 6's 3xx33x -> 333 333 remove 3's -> erased
Here an example with overlapping matches.
11111666661 has 11 digits xxXX1666661 \ overlapping 11's 1XXxx666661 / We have 5 '1' for a total of 4 '11' matched, remove all 666661 -> remove 6's 1 -> and finally 1
Test cases
Truthy
1, 12, 21, 22, 123, 321, 322, 331, 333, 4441, 4444, 12345, 987654321, 3610106226, 1010101010, 11111111111, 10812816208148888188, 82428208832101683082414123828341883888,3919555395539111955255533922519455392511539551925395511, 1515515551555515555515555551555555155555155551555155151, 999199999915999991599999999915999915999999919399999999991915999999999999999999999915999999929999999, 10121111011011011011011011011011011012110110110121101110110121111011123101101101101121011011110110111, 15101251011012229752519101110101010101010111111101101101101101111011011011011110111101101101101101915, 2020220202202022020220202232020220202202022020223220232020222220220222202202202202202202202202202202202220223202202202202202202202202222022022022022022022222202202202202202222022022022022022023876543213
Falsy
0, 2, 9, 10, 11, 23, 233, 4440, 50022, 50044, 1101010101, 11131111311, 121666626162, 181811818128181818, 127271272722672224724122727122712242722472727272722472727272247272127272, 1001023010023100160010010010010061110250100123001001001230061001010100102370100610016001001001110230, 1241242212412241241241241241241241241241241241141624124114241241241242612412412416241222412411424221241244124142412412144124, 108484298442981044294284942984429844294291042942942942849429429484284948429484842942942984104842984429429844298448429429429429429429429428494294294842942942948429428484942942942942984429429844284948429428494842849484284942942942942942984484294294284942942942942942942942942942910429429484294294
This is code-golf, standard rules apply.
Input can be given in any convenient method.
Output any two different values telling if the number is lengthy or not lengthy.
2244668810121416182022
is falsy because you can't leave the leading22
until the end? \$\endgroup\$11111111111
is truthy, since removing11
without overlap becomes1
, which we can then also remove. You may also want to change "from it ( including overlapping matches )" to "from it, including overlapping matches", since it's a pretty big part of the challenge and makes it for some languages quite a bit more tricky. \$\endgroup\$