Cody

# Problem 79. DNA N-Gram Distribution

Solution 2659523

Submitted on 6 Jul 2020
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))

ngrams = 7×3 char array 'AAA' 'AAA' 'CCC' 'TTT' 'GGG' 'AAA' 'AAA' ngrams = 7×3 char array 'AAC' 'ACT' 'CTG' 'TGA' 'GAA' 'AAC' 'ACG' hifreq = 'AAC'

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

ngrams = 22×2 char array 'dd' 'yy' 'nn' 'aa' 'mm' 'ii' 'cc' ' ' 'rr' 'oo' 'uu' 'tt' 'ii' 'nn' 'gg' ' ' 'ss' 'ee' 'rr' 'vv' 'ii' 'cc' ngrams = 22×2 char array 'dy' 'yn' 'na' 'am' 'mi' 'ic' 'c ' ' r' 'ro' 'ou' 'ut' 'ti' 'in' 'ng' 'g ' ' s' 'se' 'er' 'rv' 'vi' 'ic' 'ce' hifreq = 'ic'

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

ngrams = 39×5 char array 'YYYYY' 'ooooo' 'uuuuu' 'rrrrr' ' ' 'vvvvv' 'eeeee' 'rrrrr' 'aaaaa' 'ccccc' 'iiiii' 'ttttt' 'yyyyy' ' ' 'iiiii' 'sssss' ' ' 'eeeee' 'xxxxx' 'ccccc' 'eeeee' 'eeeee' 'ddddd' 'eeeee' 'ddddd' ' ' 'bbbbb' 'yyyyy' ' ' 'yyyyy' 'ooooo' 'uuuuu' 'rrrrr' ' ' 'sssss' 'aaaaa' 'ggggg' 'aaaaa' 'ccccc' ngrams = 39×5 char array 'Your ' 'our v' 'ur ve' 'r ver' ' vera' 'verac' 'eraci' 'racit' 'acity' 'city ' 'ity i' 'ty is' 'y is ' ' is e' 'is ex' 's exc' ' exce' 'excee' 'xceed' 'ceede' 'eeded' 'eded ' 'ded b' 'ed by' 'd by ' ' by y' 'by yo' 'y you' ' your' 'your ' 'our s' 'ur sa' 'r sag' ' saga' 'sagac' 'agaci' 'gacit' 'acity' 'city.' hifreq = 'acity'

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

ngrams = 48×3 char array 'AAA' 'GGG' 'CCC' 'GGG' 'AAA' 'AAA' 'GGG' 'GGG' 'AAA' 'AAA' 'GGG' 'GGG' 'AAA' 'TTT' 'CCC' 'AAA' 'CCC' 'AAA' 'TTT' 'TTT' 'TTT' 'CCC' 'TTT' 'CCC' 'AAA' 'GGG' 'GGG' 'AAA' 'CCC' 'AAA' 'AAA' 'AAA' 'GGG' 'GGG' 'CCC' 'AAA' 'TTT' 'TTT' 'TTT' 'CCC' 'AAA' 'CCC' 'TTT' 'AAA' 'AAA' 'TTT' 'GGG' 'GGG' ngrams = 48×3 char array 'AGC' 'GCG' 'CGA' 'GAA' 'AAG' 'AGG' 'GGA' 'GAA' 'AAG' 'AGG' 'GGA' 'GAT' 'ATC' 'TCA' 'CAC' 'ACA' 'CAT' 'ATT' 'TTT' 'TTC' 'TCT' 'CTC' 'TCA' 'CAG' 'AGG' 'GGA' 'GAC' 'ACA' 'CAA' 'AAA' 'AAG' 'AGG' 'GGC' 'GCA' 'CAT' 'ATT' 'TTT' 'TTC' 'TCA' 'CAC' 'ACT' 'CTA' 'TAA' 'AAT' 'ATG' 'TGG' 'GGT' 'GTT' hifreq = 'AGG'

5   Fail
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))

ngrams = 98×2 char array 'II' 'nn' ' ' 'ss' 'hh' 'oo' 'rr' 'tt' ',,' ' ' 'ii' 'nn' ' ' 'mm' 'aa' 'tt' 'tt' 'ee' 'rr' 'ss' ' ' 'vv' 'ee' 'gg' 'ee' 'tt' 'aa' 'bb' 'll' 'ee' ',,' ' ' 'aa' 'nn' 'ii' 'mm' 'aa' 'll' ',,' ' ' 'aa' 'nn' 'dd' ' ' 'mm' 'ii' 'nn' 'ee' 'rr' 'aa' 'll' ',,' ' ' 'II' ' ' 'aa' 'mm' ' ' 'tt' 'hh' 'ee' ' ' 'vv' 'ee' 'rr' 'yy' ' ' 'mm' 'oo' 'dd' 'ee' 'll' ' ' 'oo' 'ff' ' ' 'aa' ' ' 'mm' 'oo' 'dd' 'ee' 'rr' 'nn' ' ' 'MM' 'aa' 'jj' 'oo' 'rr' '--' 'GG' 'ee' 'nn' 'ee' 'rr' 'aa' 'll' ngrams = 98×2 char array 'In' 'n ' ' s' 'sh' 'ho' 'or' 'rt' 't,' ', ' ' i' 'in' 'n ' ' m' 'ma' 'at' 'tt' 'te' 'er' 'rs' 's ' ' v' 've' 'eg' 'ge' 'et' 'ta' 'ab' 'bl' 'le' 'e,' ', ' ' a' 'an' 'ni' 'im' 'ma' 'al' 'l,' ', ' ' a' 'an' 'nd' 'd ' ' m' 'mi' 'in' 'ne' 'er' 'ra' 'al' 'l,' ', ' ' I' 'I ' ' a' 'am' 'm ' ' t' 'th' 'he' 'e ' ' v' 've' 'er' 'ry' 'y ' ' m' 'mo' 'od' 'de' 'el' 'l ' ' o' 'of' 'f ' ' a' 'a ' ' m' 'mo' 'od' 'de' 'er' 'rn' 'n ' ' M' 'Ma' 'aj' 'jo' 'or' 'r-' '-G' 'Ge' 'en' 'ne' 'er' 'ra' 'al' 'l.' hifreq = 'a'

Assertion failed.