Cody

# Problem 45282. Cryptography with A Square Matrix : Decoding

Solution 2967859

Submitted on 19 Sep 2020
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
encodedVector = [1665 1624 1541 1549 1495 1501 1013 1351 1221 1426 1153 886 1714 1680 1586 480 480 480]; keyMatrix = magic(3); y_correct = 'matlab and cody'; assert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))

Assertion failed.

2   Fail
encodedVector = [6829 6941 7028 6905 6877 6043 5432 6941 6575 6469 3236 3644 2352 2760 2828]; keyMatrix = magic(5); y_correct = 'hello world'; assert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))

Assertion failed.

3   Fail
encodedVector = [10923 12101 13961 10519 10823 12582 5974 11814 12207 5786 11120 11328 5574 10458 10625 10134 11738 13359 5710 10858 11017 9815 11533 13372 8501 8231 11476 10488 10848 12497 5890 11490 11781 5408 10098 10453 10858 11252 13568 10196 11470 13008 9790 10816 12582 8438 4418 6724 11085 11329 13084 10447 11693 13320 5616 10838 11359 5686 10890 11193 8802 7250 10343 11099 11859 13746 9094 7344 7717 9320 7584 7900 9299 7501 10795 9881 10711 12227 3300 4116 4898]; keyMatrix = [14 20 63; 54 46 5; 71 27 24]; y_correct = 'stockout is an order that cannot be satisfied, resulting in a loss of the sale.'; assert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))

Assertion failed.

4   Fail
encodedVector = [12269 11674 18982 12603 13111 18355 12051 12649 17959 6268 6567 14425 12171 11931 19559 6437 6969 15532 13056 12433 19898 5997 6612 14365 13705 13052 20746 11931 12436 17537 13161 12943 21233 5903 6679 14472 13679 11112 14066 13245 12765 20292 6054 7203 15871 13495 12716 19961 11148 11975 18284 3904 3776 5984]; keyMatrix = [7 92 23; 34 77 7; 89 66 32 ]; y_correct = 'dasiy is a small white flower with a yellow centre.'; assert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))

Assertion failed.

5   Pass
encodedVector = [11887 11494 18292 13583 12983 20497 12614 11975 19214 12529 9978 13458 11678 9327 12770 11425 9250 12418 13964 13138 20021 12986 12973 20645 13025 12806 20806 6267 6981 15454 5935 6625 14358 14067 13645 21715 13128 12874 20305 6295 7117 15810 12321 12283 19978 12114 12955 18760 12611 12631 20292 5987 7087 15540 12483 10160 13146 13880 13463 20776 12455 11733 18879 13630 13463 21169 6134 7068 15586 11995 12377 17247 13825 13363 21044 13068 12596 20311 10643 11358 16613 13548 12813 20052 11747 9495 12680 14027 13493 20760 13978 13059 20385 11816 9369 12962 13357 10720 13990 10791 11707 17391 14146 13289 20512 13630 13463 21169 11655 9467 12552 11162 12043 18462 3904 3776 5984]; keyMatrix = [7 92 23; 34 77 7; 89 66 32 ]; decodeMessage(encodedVector, keyMatrix)

ans = Columns 1 through 29 98 97 99 107 111 114 100 101 114 32 105 115 32 97 110 32 97 99 99 117 109 117 108 97 116 105 111 110 32 Columns 30 through 58 111 102 32 99 117 115 116 111 109 101 114 32 111 114 100 101 114 115 32 116 104 97 116 32 97 32 109 97 110 Columns 59 through 87 117 102 97 99 116 117 114 101 114 32 104 97 115 32 112 114 111 109 105 115 101 100 32 102 111 114 32 100 101 Columns 88 through 116 108 118 105 101 114 121 32 97 116 32 115 111 109 101 32 102 117 116 117 114 101 32 100 97 116 101 46 32 32 Column 117 32

6   Pass
encodedVector = [23314 25294 21847 18481 14593 16573 17959 19939 21334]; keyMatrix = magic(9); decodeMessage(encodedVector, keyMatrix)

ans = 97 98 99 32 32 32 32 32 32

### Community Treasure Hunt

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

Start Hunting!