Cody

Problem 79. DNA N-Gram Distribution

Solution 2659571

Submitted on 6 Jul 2020 by David K
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' 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' 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' 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' 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))

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' hifreq = 'er'