Cody

# Problem 79. DNA N-Gram Distribution

Solution 1795505

Submitted on 23 Apr 2019 by danteliujie
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
s = 'AACTGAACG'; n = 3; hifreq_correct = 'AAC'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ts = 'AAC' tc = 2 ts = 'ACT' tc = 1 ts = 'CTG' tc = 1 ts = 'TGA' tc = 1 ts = 'GAA' tc = 1 ts = 'AAC' tc = 2 ts = 'ACG' tc = 1

2   Pass
s = 'dynamic routing service'; n = 2; hifreq_correct = 'ic'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ts = 'dy' tc = 1 ts = 'yn' tc = 1 ts = 'na' tc = 1 ts = 'am' tc = 1 ts = 'mi' tc = 1 ts = 'ic' tc = 2 ts = 'c ' tc = 1 ts = ' r' tc = 1 ts = 'ro' tc = 1 ts = 'ou' tc = 1 ts = 'ut' tc = 1 ts = 'ti' tc = 1 ts = 'in' tc = 1 ts = 'ng' tc = 1 ts = 'g ' tc = 1 ts = ' s' tc = 1 ts = 'se' tc = 1 ts = 'er' tc = 1 ts = 'rv' tc = 1 ts = 'vi' tc = 1 ts = 'ic' tc = 2 ts = 'ce' tc = 1

3   Pass
s = 'Your veracity is exceeded by your sagacity.'; n = 5; hifreq_correct = 'acity'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ts = 'Your ' tc = 1 ts = 'our v' tc = 1 ts = 'ur ve' tc = 1 ts = 'r ver' tc = 1 ts = ' vera' tc = 1 ts = 'verac' tc = 1 ts = 'eraci' tc = 1 ts = 'racit' tc = 1 ts = 'acity' tc = 2 ts = 'city ' tc = 1 ts = 'ity i' tc = 1 ts = 'ty is' tc = 1 ts = 'y is ' tc = 1 ts = ' is e' tc = 1 ts = 'is ex' tc = 1 ts = 's exc' tc = 1 ts = ' exce' tc = 1 ts = 'excee' tc = 1 ts = 'xceed' tc = 1 ts = 'ceede' tc = 1 ts = 'eeded' tc = 1 ts = 'eded ' tc = 1 ts = 'ded b' tc = 1 ts = 'ed by' tc = 1 ts = 'd by ' tc = 1 ts = ' by y' tc = 1 ts = 'by yo' tc = 1 ts = 'y you' tc = 1 ts = ' your' tc = 1 ts = 'your ' tc = 1 ts = 'our s' tc = 1 ts = 'ur sa' tc = 1 ts = 'r sag' tc = 1 ts = ' saga' tc = 1 ts = 'sagac' tc = 1 ts = 'agaci' tc = 1 ts = 'gacit' tc = 1 ts = 'acity' tc = 2 ts = 'city.' tc = 1

4   Pass
s = 'AGCGAAGGAAGGATCACATTTCTCAGGACAAAGGCATTTCACTAATGGTT'; n = 3; hifreq_correct = 'AGG'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ts = 'AGC' tc = 1 ts = 'GCG' tc = 1 ts = 'CGA' tc = 1 ts = 'GAA' tc = 2 ts = 'AAG' tc = 3 ts = 'AGG' tc = 4 ts = 'GGA' tc = 3 ts = 'GAA' tc = 2 ts = 'AAG' tc = 3 ts = 'AGG' tc = 4 ts = 'GGA' tc = 3 ts = 'GAT' tc = 1 ts = 'ATC' tc = 1 ts = 'TCA' tc = 3 ts = 'CAC' tc = 2 ts = 'ACA' tc = 2 ts = 'CAT' tc = 2 ts = 'ATT' tc = 2 ts = 'TTT' tc = 2 ts = 'TTC' tc = 2 ts = 'TCT' tc = 1 ts = 'CTC' tc = 1 ts = 'TCA' tc = 3 ts = 'CAG' tc = 1 ts = 'AGG' tc = 4 ts = 'GGA' tc = 3 ts = 'GAC' tc = 1 ts = 'ACA' tc = 2 ts = 'CAA' tc = 1 ts = 'AAA' tc = 1 ts = 'AAG' tc = 3 ts = 'AGG' tc = 4 ts = 'GGC' tc = 1 ts = 'GCA' tc = 1 ts = 'CAT' tc = 2 ts = 'ATT' tc = 2 ts = 'TTT' tc = 2 ts = 'TTC' tc = 2 ts = 'TCA' tc = 3 ts = 'CAC' tc = 2 ts = 'ACT' tc = 1 ts = 'CTA' tc = 1 ts = 'TAA' tc = 1 ts = 'AAT' tc = 1 ts = 'ATG' tc = 1 ts = 'TGG' tc = 1 ts = 'GGT' tc = 1 ts = 'GTT' tc = 1

5   Pass
s = 'In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General.'; n = 2; hifreq_correct = 'er'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ts = 'In' tc = 1 ts = 'n ' tc = 3 ts = ' s' tc = 1 ts = 'sh' tc = 1 ts = 'ho' tc = 1 ts = 'or' tc = 2 ts = 'rt' tc = 1 ts = 't,' tc = 1 ts = ', ' tc = 4 ts = ' i' tc = 1 ts = 'in' tc = 2 ts = 'n ' tc = 3 ts = ' m' tc = 4 ts = 'ma' tc = 2 ts = 'at' tc = 1 ts = 'tt' tc = 1 ts = 'te' tc = 1 ts = 'er' tc = 5 ts = 'rs' tc = 1 ts = 's ' tc = 1 ts = ' v' tc = 2 ts = 've' tc = 2 ts = 'eg' tc = 1 ts = 'ge' tc = 1 ts = 'et' tc = 1 ts = 'ta' tc = 1 ts = 'ab' tc = 1 ts = 'bl' tc = 1 ts = 'le' tc = 1 ts = 'e,' tc = 1 ts = ', ' tc = 4 ts = ' a' tc = 4 ts = 'an' tc = 2 ts = 'ni' tc = 1 ts = 'im' tc = 1 ts = 'ma' tc = 2 ts = 'al' tc = 3 ts = 'l,' tc = 2 ts = ', ' tc = 4 ts = ' a' tc = 4 ts = 'an' tc = 2 ts = 'nd' tc = 1 ts = 'd ' tc = 1 ts = ' m' tc = 4 ts = 'mi' tc = 1 ts = 'in' tc = 2 ts = 'ne' tc = 2 ts = 'er' tc = 5 ts = 'ra' tc = 2 ts = 'al' tc = 3 ts = 'l,' tc = 2 ts = ', ' tc = 4 ts = ' I' tc = 1 ts = 'I ' tc = 1 ts = ' a' tc = 4 ts = 'am' tc = 1 ts = 'm ' tc = 1 ts = ' t' tc = 1 ts = 'th' tc = 1 ts = 'he' tc = 1 ts = 'e ' tc = 1 ts = ' v' tc = 2 ts = 've' tc = 2 ts = 'er' tc = 5 ts = 'ry' tc = 1 ts = 'y ' tc = 1 ts = ' m' tc = 4 ts = 'mo' tc = 2 ts = 'od' tc = 2 ts = 'de' tc = 2 ts = 'el' tc = 1 ts = 'l ' tc = 1 ts = ' o' tc = 1 ts = 'of' tc = 1 ts = 'f ' tc = 1 ts = ' a' tc = 4 ts = 'a ' tc = 1 ts = ' m' tc = 4 ts = 'mo' tc = 2 ts = 'od' tc = 2 ts = 'de' tc = 2 ts = 'er' tc = 5 ts = 'rn' tc = 1 ts = 'n ' tc = 3 ts = ' M' tc = 1 ts = 'Ma' tc = 1 ts = 'aj' tc = 1 ts = 'jo' tc = 1 ts = 'or' tc = 2 ts = 'r-' tc = 1 ts = '-G' tc = 1 ts = 'Ge' tc = 1 ts = 'en' tc = 1 ts = 'ne' tc = 2 ts = 'er' tc = 5 ts = 'ra' tc = 2 ts = 'al' tc = 3 ts = 'l.' tc = 1