Cody

Problem 213. Create a dictionary

Solution 308024

Submitted on 21 Aug 2013
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   Fail
%% 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)))

Error: Undefined variable "freepass" or class "freepass.please".

2   Fail
%% 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)))

Error: Undefined variable "freepass" or class "freepass.please".

3   Fail
%% 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)))

Error: Undefined variable "freepass" or class "freepass.please".

Suggested Problems

More from this Author1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!