Cody

Problem 79. DNA N-Gram Distribution

Solution 1811300

Submitted on 9 May 2019 by Parker Sheaffer
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))

dups = "AAC" bbb = 1 ccc = 1 hifreq = "AAC"

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

dups = "ic" bbb = 1 ccc = 1 hifreq = "ic"

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

dups = "acity" bbb = 1 ccc = 1 hifreq = "acity"

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

dups = 1×11 string array "AAG" "ACA" "AGG" "ATT" "CAC" "CAT" "GAA" "GGA" "TCA" "TTC" "TTT" bbb = 1 ccc = 11 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))

dups = 1×13 string array "al" "am" "an" "de" "er" "in" "ma" "mo" "ne" "od" "or" "ra" "ve" bbb = 1 ccc = 13 hifreq = "er"