Cody

# Problem 79. DNA N-Gram Distribution

Solution 37700

Submitted on 11 Feb 2012 by Sven
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))

unq = 'AAC' 'ACG' 'ACT' 'CTG' 'GAA' 'TGA' idx = 1 3 4 6 5 1 2 hifreq = AAC

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

unq = Columns 1 through 7 ' r' ' s' 'am' 'c ' 'ce' 'dy' 'er' Columns 8 through 14 'g ' 'ic' 'in' 'mi' 'na' 'ng' 'ou' Columns 15 through 21 'ro' 'rv' 'se' 'ti' 'ut' 'vi' 'yn' idx = Columns 1 through 10 6 21 12 3 11 9 4 1 15 14 Columns 11 through 20 19 18 10 13 8 2 17 7 16 20 Columns 21 through 22 9 5 hifreq = ic

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

unq = Columns 1 through 5 ' by y' ' exce' ' is e' ' saga' ' vera' Columns 6 through 10 ' your' 'Your ' 'acity' 'agaci' 'by yo' Columns 11 through 15 'ceede' 'city ' 'city.' 'd by ' 'ded b' Columns 16 through 20 'ed by' 'eded ' 'eeded' 'eraci' 'excee' Columns 21 through 25 'gacit' 'is ex' 'ity i' 'our s' 'our v' Columns 26 through 30 'r sag' 'r ver' 'racit' 's exc' 'sagac' Columns 31 through 35 'ty is' 'ur sa' 'ur ve' 'verac' 'xceed' Columns 36 through 38 'y is ' 'y you' 'your ' idx = Columns 1 through 10 7 25 33 27 5 34 19 28 8 12 Columns 11 through 20 23 31 36 3 22 29 2 20 35 11 Columns 21 through 30 18 17 15 16 14 1 10 37 6 38 Columns 31 through 39 24 32 26 4 30 9 21 8 13 hifreq = acity

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

unq = Columns 1 through 7 'AAA' 'AAG' 'AAT' 'ACA' 'ACT' 'AGC' 'AGG' Columns 8 through 14 'ATC' 'ATG' 'ATT' 'CAA' 'CAC' 'CAG' 'CAT' Columns 15 through 21 'CGA' 'CTA' 'CTC' 'GAA' 'GAC' 'GAT' 'GCA' Columns 22 through 28 'GCG' 'GGA' 'GGC' 'GGT' 'GTT' 'TAA' 'TCA' Columns 29 through 32 'TCT' 'TGG' 'TTC' 'TTT' idx = Columns 1 through 10 6 22 15 18 2 7 23 18 2 7 Columns 11 through 20 23 20 8 28 12 4 14 10 32 31 Columns 21 through 30 29 17 28 13 7 23 19 4 11 1 Columns 31 through 40 2 7 24 21 14 10 32 31 28 12 Columns 41 through 48 5 16 27 3 9 30 25 26 hifreq = AGG

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

unq = Columns 1 through 7 ' I' ' M' ' a' ' i' ' m' ' o' ' s' Columns 8 through 14 ' t' ' v' ', ' '-G' 'Ge' 'I ' 'In' Columns 15 through 21 'Ma' 'a ' 'ab' 'aj' 'al' 'am' 'an' Columns 22 through 28 'at' 'bl' 'd ' 'de' 'e ' 'e,' 'eg' Columns 29 through 35 'el' 'en' 'er' 'et' 'f ' 'ge' 'he' Columns 36 through 42 'ho' 'im' 'in' 'jo' 'l ' 'l,' 'l.' Columns 43 through 49 'le' 'm ' 'ma' 'mi' 'mo' 'n ' 'nd' Columns 50 through 56 'ne' 'ni' 'od' 'of' 'or' 'r-' 'ra' Columns 57 through 63 'rn' 'rs' 'rt' 'ry' 's ' 'sh' 't,' Columns 64 through 69 'ta' 'te' 'th' 'tt' 've' 'y ' idx = Columns 1 through 10 14 48 7 62 36 54 59 63 10 4 Columns 11 through 20 38 48 5 45 22 67 65 31 58 61 Columns 21 through 30 9 68 28 34 32 64 17 23 43 27 Columns 31 through 40 10 3 21 51 37 45 19 41 10 3 Columns 41 through 50 21 49 24 5 46 38 50 31 56 19 Columns 51 through 60 41 10 1 13 3 20 44 8 66 35 Columns 61 through 70 26 9 68 31 60 69 5 47 52 25 Columns 71 through 80 29 40 6 53 33 3 16 5 47 52 Columns 81 through 90 25 31 57 48 2 15 18 39 54 55 Columns 91 through 98 11 12 30 50 31 56 19 42 hifreq = er