Caveman Number Count

Run Settings
LanguageRaku
Language Version
Run Command
my @digits = <ook ookook oog ooga ug mook mookmook oogam oogum ugug>; sub sequence-count(Str:D $n --> UInt:D) { return 1 if !$n; my UInt $cnt = 0; for @digits -> $d { if $n.starts-with($d) { $cnt += sequence-count(substr($n, $d.chars)); } } return $cnt; } use Test; is sequence-count('ookookook'), 3, 'ookookook => 3'; is sequence-count('oogamookoogumook'), 2, 'oogamookoogumook => 2'; is sequence-count('oogoogumookookmookmookookookmookook'), 8, 'oogoogumookookmookmookookookmookook => 8'; is sequence-count('mookookookugoogumoogummookmookugmookookmookmook'), 8, 'mookookookugoogumoogummookmookugmookookmookmook => 8'; is sequence-count('mookmookoogamoogumookookugoogugoogammookmookookookoogoogumugugookmookoogugug'), 64, 'mookmookoogamoogumookookugoogugoogammookmookookookoogoogumugugookmookoogugug => 64'; is sequence-count('ookugugugugoogookookugugugugmookmookugugugugugookookmookmookmookmookoogmookmookoogaooga'), 16000, 'ookugugugugoogookookugugugugmookmookugugugugugookookmookmookmookmookoogmookmookoogaooga => 16000'; done-testing;
Editor Settings
Theme
Key bindings
Full width
Lines