Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 240672

Submitted on 6 May 2013 by Yaroslav

Correct

20Size
Leading solution size is 16.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%% Simple test case
words = {'uno', 'deux', 'tre'};
definitions = {'Spanish', 'French', 'Italian'};
d = createDictionary(words, definitions);
order = [2 1 3];
assert(isequal(definitions(order), cellfun(d, words(order), 'UniformOutput', false)))

                    
2
Pass
 
%% Nearly identical words
words = {'CamelCase', 'camelCase', 'camel case', 'CAMELCASE'};
definitions = {'More properly MixedCase', 'Also known as nerdCaps', ...
     'A dromedary valise', 'Why are you shouting?'};
d = createDictionary(words, definitions);
order = [4 2 1 3];
assert(isequal(definitions(order), cellfun(d, words(order), 'UniformOutput', false)))

                    
3
Pass
 
%% Words with punctuation
words = {'J.R.R. Tolkien', 'George R.R. Martin', '#!', 'Ke$ha'};
definitions = {'LoTR', 'GoT', 'Shebang', 'Don''t ask'};
d = createDictionary(words, definitions);
order = [4 1 3 2];
assert(isequal(definitions(order), cellfun(d, words(order), 'UniformOutput', false)))