Determine number of sequences for set of strings under the constraint that all same characters must be contiguous. The large case could have 26! or more permutations.
Input: s, string of N space separated string segments of letters [a..z]. 1<=N<=100. Total letters <=100.
Output: val, number of possible sequences, modulo 1,000,000,007
Example: Small Train Case examples
ab bbbc cd Val=1 as only abbbbccd can be created
aa aa bc c Val=4 aa gives 2 positions, aa'aa''bcc,aa''aa'bcc, bcccaa'aa'',bcccaa''aa'
abc bcd Val=0 as c is internal and thus can not connect to c of abc
Large Case specific info. See Usage of java math for unlimited precision. Note intValue gives more precision than floatValue. No java factorial exists so a function, non-recursive, is suggested. The small solution can be converted via java BigInteger factorial, mod, multiply, and intValue to solve the large case.
Additional GJam solutions can be found at Example GJam Matlab solutions. Select Find Solutions, change Language to Matlab. The Test Suite, at the bottom, contains a full GJam Small Matlab solution. No Valid Matlab solutions were submitted during the contest.
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers2
Suggested Problems
-
Which values occur exactly three times?
5234 Solvers
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2535 Solvers
-
Back to basics 23 - Triangular matrix
1117 Solvers
-
967 Solvers
-
85 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Can you please check the test suite as test 30 is uncomplete ? Thanks.
Updated test suite to fix the cropping. 10/1/2020