Cody

Problem 42716. Number of occurrences of letter in a text

Solution 1615002

Submitted on 23 Aug 2018 by Srishti Saha
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
input_text = 'bla, BLA, bla'; occurrence_correct = [3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; assert(isequal(letters_occurrence(input_text),occurrence_correct))

letters = 'abcdefghijklmnopqrstuvwxyz' occ = [] append = 3 occ = 3 append = 3 occ = 3 3 append = 0 occ = 3 3 0 append = 0 occ = 3 3 0 0 append = 0 occ = 3 3 0 0 0 append = 0 occ = 3 3 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 append = 3 occ = 3 3 0 0 0 0 0 0 0 0 0 3 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 append = 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 occ = 3 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0

2   Pass
input_text = {'King Richard: A horse, a horse! My kingdom for a horse!'}; occurrence_correct = [4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 0 0 0 1 0]; assert(isequal(letters_occurrence(input_text),occurrence_correct))

letters = 'abcdefghijklmnopqrstuvwxyz' occ = [] append = 4 occ = 4 append = 0 occ = 4 0 append = 1 occ = 4 0 1 append = 2 occ = 4 0 1 2 append = 3 occ = 4 0 1 2 3 append = 1 occ = 4 0 1 2 3 1 append = 2 occ = 4 0 1 2 3 1 2 append = 4 occ = 4 0 1 2 3 1 2 4 append = 3 occ = 4 0 1 2 3 1 2 4 3 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 append = 2 occ = 4 0 1 2 3 1 2 4 3 0 2 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 append = 2 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 append = 2 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 append = 5 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 append = 6 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 append = 3 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 0 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 0 0 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 0 0 0 append = 1 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 0 0 0 1 append = 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 0 0 0 1 0 occ = 4 0 1 2 3 1 2 4 3 0 2 0 2 2 5 0 0 6 3 0 0 0 0 0 1 0

3   Pass
input_text = {'Thus much let me avow--'; 'You are not wrong, who deem'; 'That my days have been a dream;'}; occurrence_correct = [7 1 1 3 9 0 1 5 0 0 0 1 5 3 5 0 0 3 2 5 3 2 3 0 3 0]; assert(isequal(letters_occurrence(input_text),occurrence_correct))

letters = 'abcdefghijklmnopqrstuvwxyz' occ = [] append = 1 1 5 occ = 1 1 5 append = 0 0 1 occ = 1 0 1 0 5 1 append = 1 0 0 occ = 1 0 1 1 0 0 5 1 0 append = 0 1 2 occ = 1 0 1 0 1 0 0 1 5 1 0 2 append = 2 3 4 occ = 1 0 1 0 2 1 0 0 1 3 5 1 0 2 4 append = 0 0 0 occ = 1 0 1 0 2 0 1 0 0 1 3 0 5 1 0 2 4 0 append = 0 1 0 occ = 1 0 1 0 2 0 0 1 0 0 1 3 0 1 5 1 0 2 4 0 0 append = 2 1 2 occ = 1 0 1 0 2 0 0 2 1 0 0 1 3 0 1 1 5 1 0 2 4 0 0 2 append = 0 0 0 occ = 1 0 1 0 2 0 0 2 0 1 0 0 1 3 0 1 1 0 5 1 0 2 4 0 0 2 0 append = 0 0 0 occ = 1 0 1 0 2 0 0 2 0 0 1 0 0 1 3 0 1 1 0 0 5 1 0 2 4 0 0 2 0 0 append = 0 0 0 occ = 1 0 1 0 2 0 0 2 0 0 0 1 0 0 1 3 0 1 1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