digits made of the digits 1 through 9, plus numbers pieces and min_len. The digits 2, 3, 5 and 7 are prime; the rest are non-prime.
Cut the string into exactly pieces non-empty consecutive pieces so that:
- every piece is at least min_len long;
- every piece starts with a prime digit and ends with a non-prime one.
Count the number of such cuttings. The answer can be large, so return it modulo 10⁹ + 7.digits="2738541", pieces=2, min_len=2 → 1
A new piece can start only at a prime digit preceded by a non-prime one. The only such spot inside the string is before 5 (it follows 8), giving "2738 | 541".
digits="21212121", pieces=3, min_len=2 → 3
Cuts are possible before every 2 except the first, at positions 2, 4 and 6. Choosing two of them gives 3 ways, and every piece is at least 2 long.
digits="4235", pieces=1, min_len=1 → 0
The string starts with the non-prime 4, so no split works.
digits consists of the digits 1 through 9digits="2738541", pieces=2, min_len=2
1
Run checks the first 3 tests in your browser. Submit checks all 120 tests on the server, hidden ones included.