Cody

# Problem 45279. Cryptography with A Square Matrix : Encoding

Solution 2108664

Submitted on 28 Jan 2020 by William
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 & cody'; % keyMatrix = magic(3); % y_correct = [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]; % assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

2   Pass
% inputString = 'matlab & cody' % keyMatrix = magic(5); % y_correct = [6616 6868 6820 7017 6934 4213 4712 3896 3055 3559 5144 4860 3961 5377 6398]; % assert(isequal(encodeMessage(inputString, keyMatrix),y_correct))

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'