Problem 2325. GJam 2014 Rd 1c: Reordering Train Cars (Large)

This Challenge is derived from GJam 2014 Rd 1c: Reordering Train Cars (Large).
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

18.18% Correct | 81.82% Incorrect
Last Solution submitted on Dec 11, 2020

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers2

Suggested Problems

More from this Author294

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!