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
-
2164 Solvers
-
Test if a Number is a Palindrome without using any String Operations
253 Solvers
-
Project Euler: Problem 7, Nth prime
1753 Solvers
-
Project Euler: Problem 16, Sums of Digits of Powers of Two
178 Solvers
-
chance in percent for minimum K heads when a good coin is tossed N times?
53 Solvers
More from this Author309
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