Cody

# Problem 45279. Cryptography with A Square Matrix : Encoding

Solution 2967838

Submitted on 19 Sep 2020 by Alfonso Nieto-Castanon
• Size: 41
• This is the leading solution.
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
inputString = 'matlab and cody'; keyMatrix = magic(3); y_correct = [1665 1624 1541 1549 1495 1501 1013 1351 1221 1426 1153 886 1714 1680 1586 480 480 480]; assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

2   Pass
inputString = 'matlab and cody' keyMatrix = magic(5); y_correct = [6616 6868 6820 7017 6934 4911 6233 6245 5817 5199 5646 5344 6827 6080 6198 2080 2080 2080 2080 2080]; assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

inputString = 'matlab and cody'

3   Pass
inputString = 'Hello worlD!!'; keyMatrix = magic(3); y_correct = [1325 1477 1413 1167 1103 1495 1747 1710 1703 1130 895 1110 488 483 484]; assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

4   Pass
inputString = 'Hello worlD!!' keyMatrix = magic(5); y_correct = [6285 6205 6900 6585 6525 6043 5432 6941 6575 6469 2717 2920 2243 2471 2519]; assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

inputString = 'Hello worlD!!'

5   Pass
inputString = 'What a wonderful day!' keyMatrix = [41 6; 46 46]; y_correct = [4191 8786 4673 9798 1894 5934 2026 6946 5211 10166 4706 9246 5286 9936 5445 10350 1912 6072 4703 10028 1545 2990]; assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

inputString = 'What a wonderful day!'

6   Pass
inputString = '3' keyMatrix = [41 6; 46 46]; y_correct = [2283 3818]; assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

inputString = '3'

### Community Treasure Hunt

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

Start Hunting!