{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":55070,"title":"Caesar Cipher Shift","description":"Given a word and its encrypted version using the caesar cipher, find the shift used.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGiven a word and its encrypted version using the caesar cipher, find the shift used.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function n = shift(d, e)\r\n  n = 0;\r\nend","test_suite":"%%\r\nd = 'Hello'\r\ne = 'Mjqqt'\r\nn_correct = 5;\r\nassert(isequal(shift(d, e), n_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":2446480,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-13T07:49:24.000Z","updated_at":"2026-02-10T08:53:18.000Z","published_at":"2022-07-13T07:49:24.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a word and its encrypted version using the caesar cipher, find the shift used.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1151,"title":"Decrypt Polybius ","description":"Decrypt Polybius square. Please refer to  Problem 1150 Polybius Square.\r\ninput [13 33 14 51] output 'cody';\r\ninput [23 0 26 33 44 15 0 31 11 42 26 11 12] returns 'i love matlab'.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 81px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 40.5px; transform-origin: 407px 40.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 129.5px 8px; transform-origin: 129.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eDecrypt Polybius square. Please refer to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 1150 Polybius Square.\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 103.5px 8px; transform-origin: 103.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput [13 33 14 51] output 'cody';\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 211.5px 8px; transform-origin: 211.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput [23 0 26 33 44 15 0 31 11 42 26 11 12] returns 'i love matlab'.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = decrypt_polybius(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [13 33 14 51];\r\ny_correct = 'cody';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [23 0 26 33 44 15 0 31 11 42 26 11 12] ;\r\ny_correct = 'i love matlab';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [34 33 26 51 12 23 43 41];\r\ny_correct = 'polybius';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [31 11 42 22 45 33 36 25 41 0 31 11 14 15 0 31 11 42 26 11 12];\r\ny_correct = 'mathworks made matlab';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [51 33 0 41 43 34];\r\ny_correct = 'yo sup';\r\nassert(isequal(decrypt_polybius(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":35,"test_suite_updated_at":"2021-07-18T13:37:06.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-30T14:26:09.000Z","updated_at":"2025-08-14T15:41:08.000Z","published_at":"2012-12-30T14:26:09.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDecrypt Polybius square. Please refer to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 1150 Polybius Square.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput [13 33 14 51] output 'cody';\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput [23 0 26 33 44 15 0 31 11 42 26 11 12] returns 'i love matlab'.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":45282,"title":"Cryptography with A Square Matrix : Decoding","description":"Previous Problem: Cryptography with A Square Matrix : Encoding\r\nNow decode a double vector to a (hopefully!) meaningful text.\r\nInputs are encoded vector and key matrix.\r\n   encodedVector = [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\r\n\r\n   key = magic(3);\r\ninverse of key\r\n   inverseKey = [0.147222222222222 -0.144444444444444 0.0638888888888889\r\n               -0.0611111111111111 0.0222222222222222 0.105555555555556\r\n               -0.0194444444444445 0.188888888888889 -0.102777777777778];\r\nReshape encodedVector so it has the same number of rows with key\r\n   reshapedVector = [1665 1549 486 1503 1192;\r\n                     1624 1495 510 1552 747;\r\n                     1541 1501 534 1595 836];\r\nMultiply inverseKey and reshapedVector, round it and reshape it;\r\n messageVector = [109 97 116 108 97 98 32 38 32 99 111 100 121 32 32];\r\nchar equivalent of message vector is 'matlab \u0026 cody'","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 449.333px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 224.667px; transform-origin: 407px 224.667px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 57.5px 8px; transform-origin: 57.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePrevious Problem:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/45279-cryptography-with-a-square-matrix-encoding\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eCryptography with A Square Matrix : Encoding\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 193px 8px; transform-origin: 193px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNow decode a double vector to a (hopefully!) meaningful text.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 31.5px 8px; transform-origin: 31.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInputs are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 56px 8px; transform-origin: 56px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eencoded vector\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12px 8px; transform-origin: 12px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ekey\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22.5px 8px; transform-origin: 22.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 360px 8.5px; tab-size: 4; transform-origin: 360px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   encodedVector = [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   key = magic(3);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 31px 8px; transform-origin: 31px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einverse of\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12px 8px; transform-origin: 12px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ekey\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 288px 8.5px; tab-size: 4; transform-origin: 288px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   inverseKey = [0.147222222222222 -0.144444444444444 0.0638888888888889\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 284px 8.5px; tab-size: 4; transform-origin: 284px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e               -0.0611111111111111 0.0222222222222222 0.105555555555556\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 292px 8.5px; tab-size: 4; transform-origin: 292px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e               -0.0194444444444445 0.188888888888889 -0.102777777777778];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReshape\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 53.5px 8px; transform-origin: 53.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eencodedVector\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 124px 8px; transform-origin: 124px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e so it has the same number of rows with\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12px 8px; transform-origin: 12px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ekey\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 180px 8.5px; tab-size: 4; transform-origin: 180px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   reshapedVector = [1665 1549 486 1503 1192;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 176px 8.5px; tab-size: 4; transform-origin: 176px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                     1624 1495 510 1552 747;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 180px 8.5px; tab-size: 4; transform-origin: 180px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                     1541 1501 534 1595 836];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 23.5px 8px; transform-origin: 23.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eMultiply\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40px 8px; transform-origin: 40px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003einverseKey\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 56px 8px; transform-origin: 56px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ereshapedVector\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 77.5px 8px; transform-origin: 77.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, round it and reshape it;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 280px 8.5px; tab-size: 4; transform-origin: 280px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e messageVector = [109 97 116 108 97 98 32 38 32 99 111 100 121 32 32];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 165px 8px; transform-origin: 165px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003echar equivalent of message vector is 'matlab \u0026amp; cody'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function hopefullyMeaningfulText = decodeMessage(encodedVector, keyMatrix)\r\n\r\nend","test_suite":"%%\r\nencodedVector = [1665 1624 1541 1549 1495 1501 1013 1351 1221 1426 1153 886 1714 1680 1586 480 480 480];\r\nkeyMatrix = magic(3);\r\ny_correct = 'matlab and cody';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [6829 6941 7028 6905 6877 6043 5432 6941 6575 6469 3236 3644 2352 2760 2828];\r\nkeyMatrix = magic(5);\r\ny_correct = 'hello world';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [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];\r\nkeyMatrix = [14 20 63; 54 46 5; 71 27 24];\r\ny_correct = 'stockout is an order that cannot be satisfied, resulting in a loss of the sale.';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [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];\r\nkeyMatrix = [7 92 23; 34 77 7; 89 66 32 ];\r\ny_correct = 'dasiy is a small white flower with a yellow centre.';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [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];\r\nkeyMatrix = [7 92 23; 34 77 7; 89 66 32 ];\r\ndecodeMessage(encodedVector, keyMatrix)\r\n\r\n%%\r\nencodedVector = [23314 25294 21847 18481 14593 16573 17959 19939 21334];\r\nkeyMatrix = magic(9);\r\ndecodeMessage(encodedVector, keyMatrix)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":8703,"edited_by":223089,"edited_at":"2022-12-28T13:35:31.000Z","deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2022-12-28T13:35:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-01-28T08:55:42.000Z","updated_at":"2025-06-15T06:19:47.000Z","published_at":"2020-01-28T08:56:34.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious Problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45279-cryptography-with-a-square-matrix-encoding\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCryptography with A Square Matrix : Encoding\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNow decode a double vector to a (hopefully!) meaningful text.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInputs are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eencoded vector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   encodedVector = [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\\n\\n   key = magic(3);]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einverse of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   inverseKey = [0.147222222222222 -0.144444444444444 0.0638888888888889\\n               -0.0611111111111111 0.0222222222222222 0.105555555555556\\n               -0.0194444444444445 0.188888888888889 -0.102777777777778];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReshape\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eencodedVector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e so it has the same number of rows with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   reshapedVector = [1665 1549 486 1503 1192;\\n                     1624 1495 510 1552 747;\\n                     1541 1501 534 1595 836];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMultiply\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einverseKey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereshapedVector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, round it and reshape it;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ messageVector = [109 97 116 108 97 98 32 38 32 99 111 100 121 32 32];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003echar equivalent of message vector is 'matlab \u0026amp; cody'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1150,"title":"Polybius Square","description":"Given a string, calculate the coordinates. Input will be always in lowercase. If string is a sentence then use 0 (zero) to indicate the space between words.\r\n   1 2 3 4 5 6\r\n1  a b c d e f \r\n2  g h i j k l\r\n3  m n o p q r\r\n4  s t u v w x\r\n5  y z\r\ninput 'cody' returns [13 33 14 51] and\r\ninput 'i love matlab' returns [23 0 26 33 44 15 0 31 11 42 26 11 12].\r\nFor more information refer to. Please note that another colum (6th column) is added in order to seperate letter i and letter j. That means table in this question is different from reference page.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 286.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 143.3px; transform-origin: 407px 143.3px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a string, calculate the coordinates. Input will be always in lowercase. If string is a sentence then use 0 (zero) to indicate the space between words.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 61.3px; transform-origin: 404px 61.3px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   1 2 3 4 5 6\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e1  a \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 40px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 40px 8.5px; \"\u003eb c d e f \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e2  g \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003eh i j k l\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e3  m \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003en o p q r\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e4  s \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003et u v w x\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 24px 8.5px; transform-origin: 24px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e5  y \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 4px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 4px 8.5px; \"\u003ez\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 118px 8px; transform-origin: 118px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput 'cody' returns [13 33 14 51] and\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 211.5px 8px; transform-origin: 211.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput 'i love matlab' returns [23 0 26 33 44 15 0 31 11 42 26 11 12].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 66px 8px; transform-origin: 66px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor more information\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003erefer to\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 293px 8px; transform-origin: 293px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Please note that another colum (6th column) is added in order to seperate letter i and letter j. That means table in this question is different from reference page.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = polybius(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'do not cheat';\r\ny_correct = [14 33 0 32 33 42 0 13 22 15 11 42];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'cody';\r\ny_correct = [13 33 14 51];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'polybius';\r\ny_correct = [34 33 26 51 12 23 43 41];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'i love matlab';\r\ny_correct = [23 0 26 33 44 15 0 31 11 42 26 11 12];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'covid is a deadly virus';\r\ny_correct = [13 33 44 23 14 0 23 41 0 11 0 14 15 11 14 26 51 0 44 23 36 43 41];\r\nassert(isequal(polybius(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":"2021-07-18T13:42:32.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-30T13:33:11.000Z","updated_at":"2026-03-16T11:33:34.000Z","published_at":"2012-12-30T14:03:05.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a string, calculate the coordinates. Input will be always in lowercase. If string is a sentence then use 0 (zero) to indicate the space between words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   1 2 3 4 5 6\\n1  a b c d e f \\n2  g h i j k l\\n3  m n o p q r\\n4  s t u v w x\\n5  y z]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput 'cody' returns [13 33 14 51] and\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput 'i love matlab' returns [23 0 26 33 44 15 0 31 11 42 26 11 12].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor more information\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erefer to\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Please note that another colum (6th column) is added in order to seperate letter i and letter j. That means table in this question is different from reference page.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":54835,"title":"Caesar Cipher","description":"Given a input word x and a shift n, encrypt the word with caesar cipher of shift n.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGiven a input word x and a shift n, encrypt the word with caesar cipher of shift n.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = caesar_cipher(x, n)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'Hello';\r\nn = 5;\r\ny_correct = 'Mjqqt';\r\nassert(isequal(caesar_cipher(x, n), y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":2446480,"edited_by":2446480,"edited_at":"2022-07-12T12:55:35.000Z","deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-12T12:55:13.000Z","updated_at":"2022-07-12T12:55:35.000Z","published_at":"2022-07-12T12:55:35.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a input word x and a shift n, encrypt the word with caesar cipher of shift n.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":751,"title":"Implement simple rotation cypher","description":"If given a letter from the set:\r\n\r\n  [abc...xyz]\r\n\r\nand a shift, implement a shift cypher.\r\n\r\nExample:\r\n\r\n  'abc' \r\n\r\nwith a shift of -1 yields\r\n\r\n  'zab'\r\n\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eIf given a letter from the set:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e[abc...xyz]\r\n\u003c/pre\u003e\u003cp\u003eand a shift, implement a shift cypher.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e'abc' \r\n\u003c/pre\u003e\u003cp\u003ewith a shift of -1 yields\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e'zab'\r\n\u003c/pre\u003e","function_template":"function outStr = cypher(inStr, shift)\r\n  outStr = inStr;\r\nend","test_suite":"%%\r\ninStr = 'doug';\r\nshift = 10;\r\noutStr = 'nyeq';\r\n\r\nassert(isequal(cypher(inStr, shift),outStr))\r\n\r\n%%\r\ninStr = 'thequickbrownfox';\r\nshift = 5;\r\noutStr = 'ymjvznhpgwtbsktc';\r\n\r\nassert(isequal(cypher(inStr, shift),outStr))\r\n\r\n%%\r\ninStr = 'thecrowfliesatmidnight';\r\nshift = 22;\r\noutStr = 'pdaynksbheaowpiezjecdp';\r\n\r\nassert(isequal(cypher(inStr, shift),outStr))","published":true,"deleted":false,"likes_count":13,"comments_count":2,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1096,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":6,"created_at":"2012-06-06T15:38:43.000Z","updated_at":"2026-02-19T13:12:57.000Z","published_at":"2012-06-08T19:08:23.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf given a letter from the set:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[[abc...xyz]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eand a shift, implement a shift cypher.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA['abc']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewith a shift of -1 yields\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA['zab']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":61050,"title":"Generate Secret Key for Cryptography ","description":"From a seed file (code.wav), decode the audio file (Bell 202 format at 200 bits/sec) into a binary stream and then convert the binary stream into a decimal vector (uint8) that should be hashed using SHA - 224, 256, 384, or 514 based on the function input. Output the hexadecimal hash (in lower case). ","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.440001px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 63px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 344px 31.5px; transform-origin: 344px 31.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 321px 31.5px; text-align: left; transform-origin: 321px 31.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFrom a seed file (code.wav), decode the audio file (Bell 202 format at 200 bits/sec) into a binary stream and then convert the binary stream into a decimal vector (uint8) that should be hashed using SHA - 224, 256, 384, or 514 based on the function input. Output the hexadecimal hash (in lower case). \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function s = generateSecretKey(d)\r\ns='ab13';\r\nend","test_suite":"%%\r\ndropboxLink = 'https://www.dropbox.com/scl/fi/9g51et5mg6oir3rzckgmq/code.wav?rlkey=kujbm4wvj8k8n2fsav36ie3fo\u0026st=udr92tru\u0026dl=1';\r\nwebsave('code.wav', dropboxLink);\r\nassert(isequal('9b9011a6f9075acc3bf9aa9d58f117d2a457df1ad4c1fc800654ed4728699654',generateSecretKey(256)));\r\nassert(isequal('b4d6dfe609125ee60a481568d23ecdd0394ee272b50ef9e901c8d3610fbf64dad79ef569607864da83b635b590edf2a82a7d300fb37f9a61664d05b1445dc3a9',generateSecretKey(512)));\r\nassert(isequal('125da2fb2c851a0ec8d1feb68e5f6b7c5e951b809e3b58400c955840',generateSecretKey(224)));\r\nassert(isequal('fa4391ce471e89fc5232aa0aa9d8ed70738fc526029370f09fd9cb4d7439e8825aeacba72ea65a6109b7a964ae4cf114',generateSecretKey(384)));\r\n%%\r\ndropboxLink = 'https://www.dropbox.com/scl/fi/ezhpy2a6u9tel2v53pdco/code1.wav?rlkey=5yg3bx0dqochp2jcalvzjs1ws\u0026st=d5ekkeuw\u0026dl=1';\r\nwebsave('code.wav', dropboxLink);\r\nassert(isequal('1fd510e7e4777fd25aa2b75468ea9949fac17fa43004c92c8f906da57a0856a2',generateSecretKey(256)));\r\nassert(isequal('48132c1a6789a3a4c161436fd9b09353767a8dad70c90f7c37bd8fe89a15cad3d961ac2c0fe594fe951ede62dca77cff4a67668bd0d35091b60ad46e547dd883',generateSecretKey(512)));\r\nassert(isequal('de27d369a5ecf458537c39fac1d7a3d5d075dfbbd251caa110a1340d',generateSecretKey(224)));\r\nassert(isequal('0e3d5fb4ec12cd4cc97d1c272afa8c3d280d1626727f4366ce41acd0ece2aeeee6357bd29aa6833b18f75a9744766fb6',generateSecretKey(384)));\r\n%%\r\ndropboxLink = 'https://www.dropbox.com/scl/fi/a2tmz2axfex2sxa1pm4f6/code2.wav?rlkey=4p50pxytoyudkgv27hnskhamr\u0026st=eocw0ote\u0026dl=1';\r\nwebsave('code.wav', dropboxLink);\r\nassert(isequal('689dd116f955d1489ae5a0b82731e8f641de70366cf153c273a5aceb0bce882d',generateSecretKey(256)));\r\nassert(isequal('0bdbb0437718cf66746eaeb083217127a165f3cb4fed63132859cf1dcc79b78ac7997d00d6460e2b9853980de69ee7819a1605488ece34c84efbfa790cad516e',generateSecretKey(512)));\r\nassert(isequal('1fc1b7790c3bc1e2f7d292befca59d5f553e272898691e37d5d68b98',generateSecretKey(224)));\r\nassert(isequal('61e71c53762b02af99b8b4b212dc4cd78ba71750ab97927d52d2d63f36fbdb26e1e203b32b87867b1e8c0ac44de2531a',generateSecretKey(384)));\r\n%%\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":145982,"edited_by":145982,"edited_at":"2025-10-27T11:40:10.000Z","deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2025-10-25T00:11:13.000Z","updated_at":"2026-02-26T14:02:17.000Z","published_at":"2025-10-25T00:11:13.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFrom a seed file (code.wav), decode the audio file (Bell 202 format at 200 bits/sec) into a binary stream and then convert the binary stream into a decimal vector (uint8) that should be hashed using SHA - 224, 256, 384, or 514 based on the function input. Output the hexadecimal hash (in lower case). \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1953,"title":"Simple Caesar Cypher - shift encrypt a message given an index number","description":"A Caesar cypher is a simple shift encryption method. Your goal is to create a function that allows a user to input a string and a shift index and outputs the shifted cypher-text as a string.\r\n\r\nThe shift index is an integer that tells the encryption method how many letters to shift each letter in the message forward. For example, a shift index of 3 will shift the letter \"a\" to be \"d\", \"b\" to be \"e\" and so on. In this problem we will just use the 26 lowercase letters in the english alphabet, and any capital letters in the message should be converted to lowercase. The ordering of letters will wrap around after \"z\", so that a \"y\" shifted by 3 will become a \"b\".\r\n\r\nAny integer number (positive, negative, and of any magnitude) should be acceptable as the shift index.\r\n\r\nExamples:\r\n\r\ncaesarShift('zebra',7) --\u003e 'gliyh'\r\n\r\ncaesarShift('LiOn',-5) --\u003e 'gdji'","description_html":"\u003cp\u003eA Caesar cypher is a simple shift encryption method. Your goal is to create a function that allows a user to input a string and a shift index and outputs the shifted cypher-text as a string.\u003c/p\u003e\u003cp\u003eThe shift index is an integer that tells the encryption method how many letters to shift each letter in the message forward. For example, a shift index of 3 will shift the letter \"a\" to be \"d\", \"b\" to be \"e\" and so on. In this problem we will just use the 26 lowercase letters in the english alphabet, and any capital letters in the message should be converted to lowercase. The ordering of letters will wrap around after \"z\", so that a \"y\" shifted by 3 will become a \"b\".\u003c/p\u003e\u003cp\u003eAny integer number (positive, negative, and of any magnitude) should be acceptable as the shift index.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003ecaesarShift('zebra',7) --\u003e 'gliyh'\u003c/p\u003e\u003cp\u003ecaesarShift('LiOn',-5) --\u003e 'gdji'\u003c/p\u003e","function_template":"function cyphertext = caesarShift(message, shift)\r\ncyphertext=message;\r\nend","test_suite":"%%\r\nmessage = 'elephant';\r\nshift = 45;\r\ncorrect = 'xexiatgm';\r\nassert(isequal(caesarShift(message,shift),correct))\r\n\r\n%%\r\nmessage = 'TiGEr';\r\nshift = -537;\r\nanswer = 'crpna';\r\nassert(isequal(caesarShift(message,shift),answer))\r\n\r\n%%\r\nmessage = 'gozoaobrsf'\r\nshift = 12;\r\nanswer = 'salamander';\r\nassert(isequal(caesarShift(message,shift),answer))\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":15293,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":110,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":28,"created_at":"2013-10-21T17:12:02.000Z","updated_at":"2026-03-06T20:51:45.000Z","published_at":"2013-10-21T17:12:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA Caesar cypher is a simple shift encryption method. Your goal is to create a function that allows a user to input a string and a shift index and outputs the shifted cypher-text as a string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe shift index is an integer that tells the encryption method how many letters to shift each letter in the message forward. For example, a shift index of 3 will shift the letter \\\"a\\\" to be \\\"d\\\", \\\"b\\\" to be \\\"e\\\" and so on. In this problem we will just use the 26 lowercase letters in the english alphabet, and any capital letters in the message should be converted to lowercase. The ordering of letters will wrap around after \\\"z\\\", so that a \\\"y\\\" shifted by 3 will become a \\\"b\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAny integer number (positive, negative, and of any magnitude) should be acceptable as the shift index.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ecaesarShift('zebra',7) --\u003e 'gliyh'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ecaesarShift('LiOn',-5) --\u003e 'gdji'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45279,"title":"Cryptography with A Square Matrix : Encoding","description":"Matrix inverse operation can be used to encode or decode of a message. For example \r\n\r\n    text = 'matlab \u0026 cody'. \r\n\r\nnumeric equivalent is \r\n\r\n    num = [109 97 116 108 97 98 32 38 32 99 111 100 121]\r\n\r\n\r\nlet \r\n\r\n   key = magic(3);\r\n\r\n\r\n*key* is an arbitrary square matrix and its inverse is exist. \r\n\r\nreshape the vector *num* so it has the same number of rows with *key* matrix\r\n\r\n   numMatrix = [109 108 32 99 121;\r\n                 97 97 38 111 32;\r\n                116 98 32 100 32];\r\n\r\nNote that last two elements are filled with 32 which is the numeric equivalent of blank character ' '.\r\n\r\nFinally multiply *key* with *numMatrix* (and reshape it) to obtain an encoded vector.\r\n\r\n   encodedVector= [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\r\n\r\nif you multiply *inverse of key* with reshaped *encodedVector* you can obtain the ascii numbers of secret message.\r\n\r\nNext Problem : \u003chttps://www.mathworks.com/matlabcentral/cody/problems/45282-cyrptography-with-a-square-matrix-decoding Cryptography with A Square Matrix : Decoding\u003e\r\n\r\nInspired from:\r\n\r\nBarnett, R.A., Ziegler, M.R. and Byleen, K.E. (2015). Finite Mathematics for Business, Economics, Life Sciences, and Social Sciences. Pearson, 13th (Global) Edition. p:245-247.","description_html":"\u003cp\u003eMatrix inverse operation can be used to encode or decode of a message. For example\u003c/p\u003e\u003cpre\u003e    text = 'matlab \u0026 cody'. \u003c/pre\u003e\u003cp\u003enumeric equivalent is\u003c/p\u003e\u003cpre\u003e    num = [109 97 116 108 97 98 32 38 32 99 111 100 121]\u003c/pre\u003e\u003cp\u003elet\u003c/p\u003e\u003cpre\u003e   key = magic(3);\u003c/pre\u003e\u003cp\u003e\u003cb\u003ekey\u003c/b\u003e is an arbitrary square matrix and its inverse is exist.\u003c/p\u003e\u003cp\u003ereshape the vector \u003cb\u003enum\u003c/b\u003e so it has the same number of rows with \u003cb\u003ekey\u003c/b\u003e matrix\u003c/p\u003e\u003cpre\u003e   numMatrix = [109 108 32 99 121;\r\n                 97 97 38 111 32;\r\n                116 98 32 100 32];\u003c/pre\u003e\u003cp\u003eNote that last two elements are filled with 32 which is the numeric equivalent of blank character ' '.\u003c/p\u003e\u003cp\u003eFinally multiply \u003cb\u003ekey\u003c/b\u003e with \u003cb\u003enumMatrix\u003c/b\u003e (and reshape it) to obtain an encoded vector.\u003c/p\u003e\u003cpre\u003e   encodedVector= [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\u003c/pre\u003e\u003cp\u003eif you multiply \u003cb\u003einverse of key\u003c/b\u003e with reshaped \u003cb\u003eencodedVector\u003c/b\u003e you can obtain the ascii numbers of secret message.\u003c/p\u003e\u003cp\u003eNext Problem : \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/45282-cyrptography-with-a-square-matrix-decoding\"\u003eCryptography with A Square Matrix : Decoding\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInspired from:\u003c/p\u003e\u003cp\u003eBarnett, R.A., Ziegler, M.R. and Byleen, K.E. (2015). Finite Mathematics for Business, Economics, Life Sciences, and Social Sciences. Pearson, 13th (Global) Edition. p:245-247.\u003c/p\u003e","function_template":"function encodedVector = encodeMessage(inputString,keyMatrix)\r\n\r\nend","test_suite":"%%\r\ninputString = 'matlab and cody';\r\nkeyMatrix = magic(3);\r\ny_correct = [1665 1624 1541 1549 1495 1501 1013 1351 1221 1426 1153 886 1714 1680 1586 480 480 480];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n%%\r\ninputString = 'matlab and cody'\r\nkeyMatrix = magic(5);\r\ny_correct = [6616 6868 6820 7017 6934 4911 6233 6245 5817 5199 5646 5344 6827 6080 6198 2080 2080 2080 2080 2080];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n%%\r\ninputString = 'Hello worlD!!';\r\nkeyMatrix = magic(3);\r\ny_correct = [1325 1477 1413 1167 1103 1495 1747 1710 1703 1130 895 1110 488 483 484];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n%%\r\ninputString = 'Hello worlD!!'\r\nkeyMatrix = magic(5);\r\ny_correct = [6285 6205 6900 6585 6525 6043 5432 6941 6575 6469 2717 2920 2243 2471 2519];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n\r\n%%\r\ninputString = 'What a wonderful day!'\r\nkeyMatrix = [41 6; 46 46];\r\ny_correct = [4191 8786 4673 9798 1894 5934 2026 6946 5211 10166 4706 9246 5286 9936 5445 10350 1912 6072 4703 10028 1545 2990];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n\r\n%%\r\ninputString = '3'\r\nkeyMatrix = [41 6; 46 46];\r\ny_correct = [2283 3818];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":"2020-01-28T16:27:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-01-27T13:50:56.000Z","updated_at":"2020-01-28T16:27:49.000Z","published_at":"2020-01-28T08:56:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMatrix inverse operation can be used to encode or decode of a message. For example\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    text = 'matlab \u0026 cody'.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003enumeric equivalent is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    num = [109 97 116 108 97 98 32 38 32 99 111 100 121]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003elet\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   key = magic(3);]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is an arbitrary square matrix and its inverse is exist.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ereshape the vector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enum\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e so it has the same number of rows with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e matrix\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   numMatrix = [109 108 32 99 121;\\n                 97 97 38 111 32;\\n                116 98 32 100 32];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that last two elements are filled with 32 which is the numeric equivalent of blank character ' '.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFinally multiply\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enumMatrix\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (and reshape it) to obtain an encoded vector.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   encodedVector= [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif you multiply\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einverse of key\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e with reshaped\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eencodedVector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e you can obtain the ascii numbers of secret message.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNext Problem :\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45282-cyrptography-with-a-square-matrix-decoding\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCryptography with A Square Matrix : Decoding\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInspired from:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBarnett, R.A., Ziegler, M.R. and Byleen, K.E. (2015). Finite Mathematics for Business, Economics, Life Sciences, and Social Sciences. Pearson, 13th (Global) Edition. p:245-247.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44351,"title":"Code breaker, Part I:  Operation Phoenix","description":"You have been tasked with decoding a set of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).  \r\n\r\nYou can also assume that the original message will relate to an activity that is referred to by those involved as \"Operation Phoenix\". Therefore the phrase \"Operation Phoenix\" (with that capitalisation) would have appeared at least once in the original message.  \r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e];  (2)  the decoded message [as \u003chttp://au.mathworks.com/help/matlab/ref/char.html character array\u003e].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".  \r\n\r\nEXAMPLE\r\n\r\nSuppose the original message was _\"Cancel Operation Phoenix immediately \u0026 escape.\"_ and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the encoded message would be:  _\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.\"_\r\n\r\nThe correct answer would comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = 'Cancel Operation Phoenix immediately \u0026 escape.'\r\n\r\n|Note: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\r\n\r\n----------\r\n\r\nNext problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44356 Operation Orthos\u003e.\r\n\r\n----------\r\n\r\nStatistics on solutions submitted as at 15 October 2017:\r\n\r\n* *Fastest wall time to decode 5000 messages = 93 milliseconds* , for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303 Solution 1279303\u003e, with a size-based score of 40. \r\n* *Smallest size-based score = 38* , for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780 Solution 1278780\u003e, for which wall time to decode 5000 messages = 515 milliseconds.  \r\n* Best combined score = 49, for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303 Solution 1279303\u003e. ","description_html":"\u003cp\u003eYou have been tasked with decoding a set of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).\u003c/p\u003e\u003cp\u003eYou can also assume that the original message will relate to an activity that is referred to by those involved as \"Operation Phoenix\". Therefore the phrase \"Operation Phoenix\" (with that capitalisation) would have appeared at least once in the original message.\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e];  (2)  the decoded message [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter array\u003c/a\u003e].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cp\u003eSuppose the original message was \u003ci\u003e\"Cancel Operation Phoenix immediately \u0026 escape.\"\u003c/i\u003e and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the encoded message would be:  \u003ci\u003e\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.\"\u003c/i\u003e\u003c/p\u003e\u003cp\u003eThe correct answer would comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = 'Cancel Operation Phoenix immediately \u0026 escape.'\r\n\u003c/pre\u003e\u003cp\u003e\u003ctt\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003eNext problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44356\"\u003eOperation Orthos\u003c/a\u003e.\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003eStatistics on solutions submitted as at 15 October 2017:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003cb\u003eFastest wall time to decode 5000 messages = 93 milliseconds\u003c/b\u003e , for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\"\u003eSolution 1279303\u003c/a\u003e, with a size-based score of 40.\u003c/li\u003e\u003cli\u003e\u003cb\u003eSmallest size-based score = 38\u003c/b\u003e , for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780\"\u003eSolution 1278780\u003c/a\u003e, for which wall time to decode 5000 messages = 515 milliseconds.\u003c/li\u003e\u003cli\u003eBest combined score = 49, for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\"\u003eSolution 1279303\u003c/a\u003e.\u003c/li\u003e\u003c/ul\u003e","function_template":"function s = decode(x)\r\n  s = x;\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions, \r\n% so your score/size may therefore change over time.  \r\n\r\n\r\n%% Test 1\r\nx = 'Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.';\r\ns_correct.shift = 1;\r\ns_correct.message = 'Cancel Operation Phoenix immediately \u0026 escape.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 2\r\nx = 'Vwlyhapvu Wovlupe ilnpuz Ablzkhf!  Vwlyhapvu Wovlupe pz vby avw wypvypaf.';\r\ns_correct.shift = 7;\r\ns_correct.message = 'Operation Phoenix begins Tuesday!  Operation Phoenix is our top priority.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 3\r\nx = 'Eatpht cdit iwpi iwt ephhldgs wph qttc rwpcvts ugdb \"Fxeudyn\" id \"Dvcsbwl\".  Diwtglxht Detgpixdc Ewdtcxm xh egdrttsxcv prrdgsxcv id eapc.';\r\ns_correct.shift = 15;\r\ns_correct.message = 'Please note that the password has been changed from \"Qipfojy\" to \"Ogndmhw\".  Otherwise Operation Phoenix is proceeding according to plan.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 4\r\nx = 'Mncpyrgml Nfmclgv qryprcb rfpcc bywq yem.  Yjj ncpqmllcj ypc rm pckygl ml bsrw slrgj Mncpyrgml Nfmclgv gq amknjcrcb.';\r\ns_correct.shift = 24;\r\ns_correct.message = 'Operation Phoenix started three days ago.  All personnel are to remain on duty until Operation Phoenix is completed.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Rescoring \r\n% Acknowledgements \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Initialise\r\nx = 'Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.';\r\ncutoffTimeBig = 1000; % Maximum allowable walltime (in milliseconds) to run function in a loop with qBig iterations.\r\n\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\n\r\n% Run once, untimed?\r\nincludeOverheads = false;\r\nif includeOverheads, \r\n    solution = decode( x );\r\nend;\r\n\r\n% *** PRELIMINARY TIMING ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nqSmall = 50;\r\nqBig = 5000;\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0) * 1000;\r\ndisp('     -----=====-----     ')\r\nfprintf('Your wall time to decode %u messages = %i msec.\\n\\r', qSmall, floor(dt))\r\nfprintf('Your APPROXIMATE wall time to decode %u messages would be ~ %i msec.\\n\\r', qBig, ceil(dt * qBig / qSmall))\r\ndisp('     -----=====-----     ')\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\ndisp('     -----=====|||||=====-----     ')\r\ndt = etime(clock, t0) * 1000;\r\nfprintf('Your wall time to decode %u messages = %i msec.\\n\\r', qBig, floor(dt))\r\n\r\ndt_cpu = (cputime - t0_cpu) * 1000;\r\nfprintf(' ( Your CPU time for this = %i msec. ) \\n\\r', floor(dt_cpu))\r\n\r\nfDecode = @()   decode(x);\r\ndt_timeit = timeit( fDecode ) * 1000;\r\nfprintf(' [ Your ''timeit'' time to decode %u messages = %i msec. ] \\n\\r', qBig, ceil(dt_timeit * qBig))\r\n\r\n% Display a size-based score.\r\nall_nodes = mtree('decode.m', '-file');        % This is the default in Cody.\r\nstr_nodes = mtfind(all_nodes, 'Kind', 'STRING');\r\neq_nodes = mtfind(all_nodes, 'Kind', 'EQUALS');\r\nprint_nodes = mtfind(all_nodes, 'Kind', 'PRINT');\r\nexpr_nodes = mtfind(all_nodes, 'Kind', 'EXPR');\r\n\r\nsize_score = count(all_nodes) ...\r\n +sum(str_nodes.nodesize-1) ...\r\n +2*(count(expr_nodes) ...\r\n +count(print_nodes) ...\r\n -count(eq_nodes));\r\n\r\nfprintf('Your size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score.\r\ncombinedScore = size_score  +  min( 200, floor(dt*(500/qBig)) );\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW. It must be able to finish within %u milliseconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig, 'Exceeded time limit specified in Test Suite.' )","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":45,"test_suite_updated_at":"2017-10-15T10:19:08.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2017-09-29T09:20:59.000Z","updated_at":"2026-04-02T08:27:57.000Z","published_at":"2017-09-29T13:45:26.000Z","restored_at":"2017-10-04T19:25:07.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been tasked with decoding a set of coded messages that have been intercepted.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026amp; numbers) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou can also assume that the original message will relate to an activity that is referred to by those involved as \\\"Operation Phoenix\\\". Therefore the phrase \\\"Operation Phoenix\\\" (with that capitalisation) would have appeared at least once in the original message.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to crack the codes and report back in a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]; (2) the decoded message [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]. The name of the structure array shall be \\\"s\\\", with respective fields \\\"shift\\\" and \\\"message\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the original message was\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Cancel Operation Phoenix immediately \u0026amp; escape.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. (Note that the shifting 'wraps' back around.) Thus the encoded message would be: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026amp; ftdbqf.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(1)  \\ns.message = 'Cancel Operation Phoenix immediately \u0026 escape.']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNext problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44356\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Orthos\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStatistics on solutions submitted as at 15 October 2017:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFastest wall time to decode 5000 messages = 93 milliseconds\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1279303\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with a size-based score of 40.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSmallest size-based score = 38\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1278780\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, for which wall time to decode 5000 messages = 515 milliseconds.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBest combined score = 49, for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1279303\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45211,"title":"AES SubBytes() Transformation","description":"Given a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm SubBytes() transformation and output a 16x2 character hexadecimal array. \r\n\r\nRefer to this link: \u003chttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003e\r\n\r\nFor example:\r\n\r\n  statei=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\n  stateo=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2'];","description_html":"\u003cp\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm SubBytes() transformation and output a 16x2 character hexadecimal array.\u003c/p\u003e\u003cp\u003eRefer to this link: \u003ca href = \"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\"\u003ehttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003estatei=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateo=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2'];\r\n\u003c/pre\u003e","function_template":"function stateO = SubBytes(stateI)\r\n  stateO = stateI;\r\nend","test_suite":"%%\r\nstateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateO=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n%%\r\nstateI=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2']; \r\nstateO=['82';'c5';'61';'d4';'70';'4c';'37';'c5';'cb';'08';'4a';'1c';'82';'08';'a8';'3a']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n%%\r\nstateI=['82';'c5';'61';'d4';'70';'4c';'37';'c5';'cb';'08';'4a';'1c';'82';'08';'a8';'3a']; \r\nstateO=['13';'a6';'ef';'48';'51';'29';'9a';'a6';'1f';'30';'d6';'9c';'13';'30';'c2';'80']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n%%\r\nstateI=['13';'a6';'ef';'48';'51';'29';'9a';'a6';'1f';'30';'d6';'9c';'13';'30';'c2';'80']; \r\nstateO=['7d';'24';'df';'52';'d1';'a5';'b8';'24';'c0';'04';'f6';'de';'7d';'04';'25';'cd']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-21T17:35:28.000Z","updated_at":"2025-12-28T04:07:40.000Z","published_at":"2019-11-21T17:45:04.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm SubBytes() transformation and output a 16x2 character hexadecimal array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRefer to this link:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[statei=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\\nstateo=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2'];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44356,"title":"Code breaker, Part II:  Operation Orthos","description":"You have been tasked with decoding several batches of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).  \r\n\r\nYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \"Operation Orthos\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation.  Therefore you should seek _simultaneous_ occurrence of the separate words \"Operation\" and \"Orthos\" (with any capitalisation) in messages within the given batch.  \r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e];  (2)  the decoded messages [as a \u003chttp://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta cell array\u003e (containing \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e)].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".  \r\n\r\nEXAMPLE\r\n\r\nSuppose the batch contained two encoded messages — _\"qspdffe x/ pqfsbujpo\"_ and _\"Psuipt jt HP!\"_ (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the original messages would have been:  _\"proceed w/ operation\"_ and _\"Orthos is GO!\"_ .\r\n\r\nThe correct answer would comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = {'proceed w/ operation', 'Orthos is GO!'}\r\n\r\nIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar' \u003chttp://au.mathworks.com/help/matlab/ref/nan.html NaN\u003e in both fields (no need for a cell array).  \r\n\r\n|Note:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".  \r\n\r\n----------\r\n\r\nPrevious problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351 Operation Phoenix\u003e.  Next problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44383 Operation Xiangliu\u003e.","description_html":"\u003cp\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).\u003c/p\u003e\u003cp\u003eYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \"Operation Orthos\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation.  Therefore you should seek \u003ci\u003esimultaneous\u003c/i\u003e occurrence of the separate words \"Operation\" and \"Orthos\" (with any capitalisation) in messages within the given batch.\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e];  (2)  the decoded messages [as a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\"\u003ecell array\u003c/a\u003e (containing \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e)].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cp\u003eSuppose the batch contained two encoded messages — \u003ci\u003e\"qspdffe x/ pqfsbujpo\"\u003c/i\u003e and \u003ci\u003e\"Psuipt jt HP!\"\u003c/i\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the original messages would have been:  \u003ci\u003e\"proceed w/ operation\"\u003c/i\u003e and \u003ci\u003e\"Orthos is GO!\"\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eThe correct answer would comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = {'proceed w/ operation', 'Orthos is GO!'}\r\n\u003c/pre\u003e\u003cp\u003eIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar' \u003ca href = \"http://au.mathworks.com/help/matlab/ref/nan.html\"\u003eNaN\u003c/a\u003e in both fields (no need for a cell array).\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003ePrevious problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351\"\u003eOperation Phoenix\u003c/a\u003e.  Next problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44383\"\u003eOperation Xiangliu\u003c/a\u003e.\u003c/p\u003e","function_template":"function s = decode(x)\r\n  s = x;\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions, \r\n% so the assessment of your submission may therefore change over time.  \r\nRE = regexp(fileread('decode.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'assert', 'freepass', 'tic'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any(  cellfun( @(z) ismember(z, tabooWords), RE )  ), msg)\r\n\r\n\r\n%% Test 1\r\nx =                 {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};\r\ns_correct.shift = uint8(1);\r\ns_correct.message = {'proceed w/ operation', 'Orthos is GO!'};\r\ns = decode(x);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message{1}, s_correct.message{1}) )\r\nassert( isequal(s.message{2}, s_correct.message{2}) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(s, s_correct) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'cell') )\r\nassert( isequal(class(s.message{1}), 'char') )\r\n\r\n\r\n%% Test 2\r\nx =                 {'Hfqq Ons ts 555-7839 FXFU.', 'twymtx nx ts mtqi', 'bfnynsl ktw dtzw fianhj', 'TUJWFYNTS UTXYUTSJI'};\r\ns_correct.shift = uint8(5);\r\ns_correct.message = {'Call Jin on 555-7839 ASAP.', 'orthos is on hold', 'waiting for your advice', 'OPERATION POSTPONED'};\r\ns = decode(x);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 3\r\nx =                 {'Ocz kvnnrjmy rvn xcvibzy: \"Knpdko\" oj \"Gjlzgk\".', 'Jkzmvodji Kcjzids rvn npxxznnapg. Izso rdgg wz Jmocjn.', 'Edi Uvkxgzout rdgg wz gzvydib Ozvh V'};\r\ns_correct.shift = uint8(21);\r\ns_correct.message = {'The password was changed: \"Psuipt\" to \"Loqelp\".', 'Operation Phoenix was successful. Next will be Orthos.', 'Jin Zapcletzy will be leading Team A'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 4\r\nx =                 {'bxmzzuzs r/ adftae az fdmow', 'adftae etxp oaybxqfq uz 2 iwe', 'abqdmfuaz pmfq eturfqp nmow 2 p.', 'naawe dqoquhqp. fwe Vuz' };\r\ns_correct.shift = uint8(12);\r\ns_correct.message = {'planning f/ orthos on track', 'orthos shld complete in 2 wks', 'operation date shifted back 2 d.', 'books received. tks Jin'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 5\r\nx =                 {'Hdsffafy xgj Ghwjslagf Gjlzgk zsk gxxauasddq ugeewfuwv.  Lzak oadd tw dwv tq Lwse S, kmhhgjlwv tq Lwse T sk fwwvwv.'};\r\ns_correct.shift = uint8(18);\r\ns_correct.message = {'Planning for Operation Orthos has officially commenced.  This will be led by Team A, supported by Team B as needed.'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 6\r\nx = {'Mncpyrgml Nfmclgv qryprcb rfpcc bywq yem.  Yjj ncpqmllcj ypc rm pckygl ml bsrw slrgj Mncpyrgml Nfmclgv gq amknjcrcb.'};\r\ns_correct.shift = nan;\r\ns_correct.message = nan;\r\ns = decode(x);\r\nassert( isnan(s.shift) )\r\nassert( isnan(s.message) )\r\n\r\n\r\n%% Test 7\r\nx =                 {'Iutloxskj vgyycuxj oy tuc \"Ruwkrv\".', 'Vrgt lux uxznuy ruuqy UQ, haz tkkj suxk $$$', 'Ksgor Pot Fgvirkzfe ut xacqxb@sgzncuxqy.ius xk. Zakyjge', 'Zgrqkj zu Zkgs H.  Ngvve zu yavvuxz uvkxgzout....', 'Xk. latjy, vry zxgtylkx zu giiuatz \"YZOBKDSYX\" - ZDY', 'jUT''Z cUXXE'};\r\ns_correct.shift = uint8(6);\r\ns_correct.message = {'Confirmed password is now \"Loqelp\".', 'Plan for orthos looks OK, but need more $$$', 'Email Jin Zapcletzy on ruwkrv@mathworks.com re. Tuesday', 'Talked to Team B.  Happy to support operation....', 'Re. funds, pls transfer to account \"STIVEXMSR\" - TXS', 'dON''T wORRY'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% TIMING \r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Acknowledgements  \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% INITIALISE\r\nx = {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};\r\nqSmall = 50;\r\nqBig = 10000;\r\n%cutoffTimeBig = 10;\r\n\r\n% EDIT (2018-06-17).  Reduced time to pose reasonable challenge.\r\n% Accounted for improving Cody server speed per Problem 44655.\r\ncutoffTimeBig = 3;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\ntRef = datetime('2018-06-17', 'InputFormat','yyyy-MM-dd');\r\ntNow = datetime('now');\r\nyearsElapsed = (datenum(tNow) - datenum(tRef)) / 365.24;\r\nfprintf('\\r\\n\\r\\n\\r\\nSubmission evaluated for speed on %s.\\r\\n', datestr(tNow, 'dd mmmm yyyy'))\r\nrInf = 0.2;   delta = cutoffTimeBig - rInf;  tau = 3.6;  % Data from Problem 44655, based on Problem 963.\r\nqBig = floor( qBig * (cutoffTimeBig - rInf) * exp(yearsElapsed/tau) / delta );\r\nfprintf('\\r\\n\\r\\n\\r\\nTo account for computational power increases over time, number of iterations increased to %u.\\r\\n', qBig)\r\n% END EDIT (2018-06-17)\r\n\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\n\r\n% *** PRELIMINARY TIMING WITH timeit ***\r\nfDecode = @()   decode(x);\r\ndt_timeit = timeit( fDecode );\r\nfprintf('APPROXIMATE time to decode %u message batches ~ %2.2f seconds, according to ''timeit''.\\n\\r', qBig, dt_timeit * qBig)\r\n\r\n% *** PRELIMINARY TIMING WITH SHORT LOOP ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\ndisp('     -----=====-----     ')\r\n%fprintf('Your wall time to decode %u message batches = %i seconds.\\n\\r', qSmall, floor(dt))\r\nfprintf('APPROXIMATE wall time to decode %u message batches ~ %2.2f seconds, by extrapolating from %u batches.\\n\\r', qBig, dt * qBig / qSmall, qSmall)\r\ndisp('     -----=====-----     ')\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\ndisp('     -----=====|||||=====-----     ')\r\ndt = etime(clock, t0);\r\nfprintf('Your wall time to decode %u message batches = %2.2f seconds.\\n\\r', qBig, dt)\r\n\r\ndt_cpu = (cputime - t0_cpu);\r\nfprintf(' ( Your CPU time for this = %2.2f seconds. ) \\n\\r', dt_cpu)\r\n\r\n% Display (default) Cody size-based score.\r\nall_nodes = mtree('decode.m', '-file');\r\nsize_score = count(all_nodes);\r\nfprintf('Your Cody-standard size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score\r\ncombinedScore = size_score + round(dt * 10);\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW.  It must be able to finish within %u seconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig )","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2018-06-17T14:03:55.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2017-10-03T06:52:32.000Z","updated_at":"2026-04-02T18:15:25.000Z","published_at":"2017-10-03T11:50:21.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026amp; numbers) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \\\"Operation Orthos\\\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation. Therefore you should seek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esimultaneous\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e occurrence of the separate words \\\"Operation\\\" and \\\"Orthos\\\" (with any capitalisation) in messages within the given batch.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to crack the codes and report back in a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]; (2) the decoded messages [as a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ecell array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (containing\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e)]. The name of the structure array shall be \\\"s\\\", with respective fields \\\"shift\\\" and \\\"message\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained two encoded messages —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"qspdffe x/ pqfsbujpo\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Psuipt jt HP!\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. (Note that the shifting 'wraps' back around.) Thus the original messages would have been: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"proceed w/ operation\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Orthos is GO!\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(1)  \\ns.message = {'proceed w/ operation', 'Orthos is GO!'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/nan.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eNaN\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e in both fields (no need for a cell array).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Phoenix\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44383\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Xiangliu\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":78,"title":"Implement a ROT13 cipher","description":"Replace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if necessary). So A ? N, B ? O, and so on until Y ? L and Z ? M. Case of the output should match the case of the input, so a ? n. Non-alphabetic characters are left in place and untouched.\n\nIf\n\n s1 = 'I love MATLAB'\n\nthen\n\n s2 = 'V ybir ZNGYNO'\n\nSee the \u003chttp://en.wikipedia.org/wiki/ROT13 Wikipedia article\u003e for more info.","description_html":"\u003cp\u003eReplace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if necessary). So A ? N, B ? O, and so on until Y ? L and Z ? M. Case of the output should match the case of the input, so a ? n. Non-alphabetic characters are left in place and untouched.\u003c/p\u003e\u003cp\u003eIf\u003c/p\u003e\u003cpre\u003e s1 = 'I love MATLAB'\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre\u003e s2 = 'V ybir ZNGYNO'\u003c/pre\u003e\u003cp\u003eSee the \u003ca href=\"http://en.wikipedia.org/wiki/ROT13\"\u003eWikipedia article\u003c/a\u003e for more info.\u003c/p\u003e","function_template":"function s2 = rot13(s1)\n  s2 = s1;\nend","test_suite":"%% Test #1\n\ns1 = 'I love MATLAB';\ns2_correct = 'V ybir ZNGYNO';\nassert(isequal(rot13(s1),s2_correct))\n\n%% Test #2\n\ns1 = 'I \u003c3 MATLAB!!';\ns2_correct = 'V \u003c3 ZNGYNO!!';\nassert(isequal(rot13(s1),s2_correct))\n\n%% Test #3\n\ns1 = 'The quick fox stumbled over the confusing instructions.';\ns2_correct = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpgvbaf.';\nassert(isequal(rot13(s1),s2_correct))\n\n%% Test #4\n\ns1 = 'Snape kills Dumbledore on page 606. Also, there is no Santa.';\ns2_correct = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab Fnagn.';\nassert(isequal(rot13(s1),s2_correct))\n\n","published":true,"deleted":false,"likes_count":13,"comments_count":3,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1713,"test_suite_updated_at":"2012-01-18T01:00:28.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:28.000Z","updated_at":"2026-01-06T04:39:32.000Z","published_at":"2012-01-18T01:00:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReplace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if necessary). So A ? N, B ? O, and so on until Y ? L and Z ? M. Case of the output should match the case of the input, so a ? n. Non-alphabetic characters are left in place and untouched.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ s1 = 'I love MATLAB']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ s2 = 'V ybir ZNGYNO']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia article\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for more info.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44961,"title":"RSA decryption","description":"Decrypt a large integer string using RSA decryption given the public key (n) and private key (d). Convert the large integer decryption into an output message string with UTF-8 representation.\r\n\r\nExample:\r\n\r\n encrypted_message = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%input\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%input\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';%input\r\ndecrypted_message = 'I like to swim!';%output\r\n\r\n\r\n","description_html":"\u003cp\u003eDecrypt a large integer string using RSA decryption given the public key (n) and private key (d). Convert the large integer decryption into an output message string with UTF-8 representation.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e encrypted_message = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%input\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%input\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';%input\r\ndecrypted_message = 'I like to swim!';%output\u003c/pre\u003e","function_template":"function decrypted_message = RSA_Decrypt(encrypted_message,d,n)\r\n  decrypted_message = 'I like to swim!';\r\nend","test_suite":"%%\r\nm='158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';\r\nmessage = 'I like to swim!';\r\nassert(isequal(RSA_Decrypt(m,d,n),message))\r\n%%\r\nm='99761240327251194937668282784881225946299704960682605372368300120848092908591455333889649815054891832920433772438140697229743047905660648016064750862552787515723449901585029566883857331537912668878918706229773460108043130645834201085405226084010413433457258525704626839479467337463012332940952234541291286602023412313079939518264986360860440514106228995186076871512459300140814669747884371890194124';\r\nn='2044371069952561243871813747701535503388267616657953475148898181142012590397809234167373308955772082860082985954286137615597515257087506574051530104475374974920093127841789408014496870693507622812332673504654584870100580476794800708440785082437228308551107726064054828640053321250498545183042994878498928173976370185712833904492317580152665428272199317847097773542066059565512439224992672101163367819';\r\nd='131358569595346680469722564224349085322306406056832660693226883146757023027681686453130430199929142940992255578581548217026735077095312421736286269892515739496597527524021166625708322359741224036234988705082882699895245449017415856831226734459122764117157172961113990706104659539690141481103935528273973382371183154438463086325519326121228923730136467766036183357672350586091588640276470994058874793';\r\nmessage = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nout=RSA_Decrypt(m,n,d);\r\nassert(isequal(RSA_Decrypt(m,d,n),message))\r\n%%\r\nm='23055330962704323769878549529115024711681463755869375992447358448257597289666397997393945478297323372847937346015110864832142828615195632399869833059964395947034849804307978652470092440225822549097020437344501330227622390881049097656181781980124142659454562923055085607225529541369345564097544873012395850084756321027482195140106724706102857159831541577386517426252851135917933602432485339455137853480425755360413522537180403768732770990453717801905433194599201771294559164174484366213507079896512750859909040228686293902666244968559905065091421969981123917913807285202549025830873320919273470513619143052127674709353494599047667391749001044180280253098309127910967801244777547067797257847396027373615105278074126621948502699483945442597921239032762535839481741386676784123570880434889025648597593711911259097408384527597630246903648267481820555872340696607290773027177673329986283293168575528258578575033034179306629426942699054620008867304832513427178319015491321861291086200676826846740503213061372327825278234127270730394825241275398344604061667061892125034848354745243512927194104643800196788262228848172689053393410972717679060779374106225778531311917434399927265718394014531619654762559111657295163989321031700962115070401533540746801357628868609255941469541707984326602981168016264720519340003693219403163278843126513912057794102645161814569893320900148891952732032827189210372803453777673309727629845360314416264926243414888253428149538146304399700653423118791724424837155323935319171814705469113037576054893140065594406360362408167462563925199225169055130480445976569760198217276692195730775524801021060293503580957364539210146595506177369243830063105693396808209631409860229448190041996912370291877581261016834769083953407597967437841733812344230896457097759403613339974363380556576775192238298546579676296359906794868505900966056565863994904406875527092603782089107591766239203672780399852597928423220774857864301715176837587724591257928112610743311445186658958007825888475800717425136849205837547536117562642680';\r\nn='44842008376687803367401704855862174057751658874412319214254366772513580664834338103711248053800336314605433363839051280089244765499067546768593375603554906634041005882836398715141891796137918851678901692978242458027064144613729242304549721699241688731628849316717564354846304644497408201649639245333007226999680183209765262168096747256549932760714835163829498814356014506466022681051474161134416048209239076204778228261950266231966892099194904195589855692846886804440024833800891898474520523721428667143505915995217245366095168045283186412220277535584022415882288464175935131208288146822299727657938865855853054174274144036081729604573534323903573564345990066095029031133576597298513883268061041004553754062342541175017746399640362184228727837219293246060058323563065371426108553463224921179093569734439828568435658070810483844709529476015493154462587917722806971578721201741643550136095893915598053953011321347017522943202801820158823344592288227452688958887872572522782675644714289349442555731461112275849176682816627205790162163242534462778708459909915826953853537650009043468930450287584181263070727575137424307931682948818963610116434419852585517456098152109913486868606969385133300794635427715727859479612757775192862801547635779921771426233897718528292667112148507798722127322607462037572360649156150337532940752245966765201596748120586383127825681873289878451591957019880886587602576426267683951317718936847177641679183717321862429721190212389237395890951104472937261743929446841800523276218816808066432194473964294708564511969507018959711475230849760902049071415838600456901108854663197095849833602808088094456341330276320302662577163562657750920481798540333412112880539002713127873625438212479154166226846436038698572615482646490520911334607730484144343834476612603467400722323562384577281087071440008144012534847478593412147312743274523095010025887231371129897419306984829625295595332434377173711414555784685658774002600022998291909172576630780759729269867715816511099791566815282862210319017784751883446582453959';\r\nd='6565816445407878925089441991498747612160839198603241148969054176252198301108538816900577327681584864655900309129187116952811278662878254707896639032786256375181309679291058212467790617143590175026484896254317631677185521639888090836542092702228103896557828982761215001435908561096741216458335569193212038242350596427680660630865867932219252556141104387324837429582683296520255026128293117631961432452139374326884841820676484348718346835892309697741432400454075190738155214690226263908349465883864526754491093121291860880617807231984031261908018115438062149668224668541927056762969514272957080528641551440449912383177971011340773567381595669197227397095749281691989236351340479846140946699426488082757798251098448588056674770754671643802109836061405587518383808732642252532232749119323532411226969424472963287039513173436339822906642733903667734412972727748722945805719038892729473535651253460092450459024621811281873600606895132005494130257832946742084673535377347237875132451694131873556170785954511701761479583203082125987308962572083138475191433479413530168163642321800669575367485309537509082240852273955663933547032858727060003363699057579114677450927657082252183166216411898446363400905797006665507108575986344278988745322935954278566001664060256959781130851422164231215979527541890717097899466088129536122753240075629363188908753526503257284825826946057815889269456925910606842810401392503996936381736547569711529540423604489529836981870198914784848089842823822656591932437295439032050213520000125621624734133380868707883468507784350355251698659006842220673722867592264770652693364873913361956132623339827358272992906883218249723187904101702943978747751691915678242891407493339828656260188711974558580485287404900248093520605466868886511014909072710668999090169680693653605673085931199903788603401848851956524927526592113342563256817891019122155938256416456381627581783190684277329685396205824988569434587069719626936811661218907123975873968219302538615272967013401476757929690613750478379916399826582503908605565505';\r\nmessage = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nout=RSA_Decrypt(m,n,d);\r\nassert(isequal(RSA_Decrypt(m,d,n),message))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":"2019-09-08T23:48:25.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-08-29T18:26:28.000Z","updated_at":"2025-10-15T14:51:55.000Z","published_at":"2019-09-05T14:41:54.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDecrypt a large integer string using RSA decryption given the public key (n) and private key (d). Convert the large integer decryption into an output message string with UTF-8 representation.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ encrypted_message = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%input\\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%input\\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';%input\\ndecrypted_message = 'I like to swim!';%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44963,"title":"Mask Generation Function (MGF1) for PKCS #1 Standard utilizing Optimal Asymmetric Encryption Padding for RSA Cryptography","description":"Create Mask Generation Function (MGF1) from PKCS #1 v2.2 standard (B.2.1 page 50) at below link. Input will be character array (mgfSeed) which will need to be converted to octet array using UTF-8 representation. Output must be octet array (uint8) of length, maskLen (input). Hashing must use SHA-1 (160 - 20 byte).\r\n\r\nFor example:\r\n\r\n  mgfSeed = 'I like to swim.';%input\r\n  maskLen = 20;%input\r\n  mask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];%output\r\n\r\n\r\n\u003chttps://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 194px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97px; transform-origin: 407px 97px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCreate Mask Generation Function (MGF1) from PKCS #1 v2.2 standard (B.2.1) at below link. Input will be character array (mgfSeed) which will need to be converted to octet array using UTF-8 representation. Output must be octet array (uint8) of length, maskLen (input). Hashing must use SHA-1 (160 - 20 byte).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 60px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30px; transform-origin: 404px 30px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003emgfSeed = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'I like to swim.'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003emaskLen = 20;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003emask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%output\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function mask = mgf(mgfSeed,maskLen)\r\n    mask = []%octet array of length maskLen\r\nend","test_suite":"%%\r\nmgfSeed = 'I like to swim.';\r\nmaskLen = 20;\r\nmask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];\r\nassert(isequal(mgf(mgfSeed,maskLen),mask))\r\n%%\r\nmgfSeed = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nmaskLen = 825;\r\nmask = [40    55   251    83   143   211    49    16    87    56   109   116    17   188    72    54   231    67   125   182   223    53   149    36   246   233    71   113   113    29   176    61    74    77   205   167   179    99   172   172   212   249    53   148    13    89   253     3    85     0   155   181    94    15     8   122   120    92    29   229   229    46   192   162   252   119   243    94    52    12   133    98   161   249   152    68    69    22 156   155   229   132    30   163   102    90   217   160    36    53   185   128    74   224   105   214   134    90   188   101    98   220    43   162   251   183    72    54   219     4    44   185   199   193    31    42   129   112    74    25    81   133    70   156    38   225   243    24    50   132    79   130    42    72   145   158   105   253   190    62    73   107    95   133    78   238   214    39    88   245    40    46   166   201   173   209   234   194     3   117   226    32   176    12   139    83   211    67   101    99   174   126   103   130    83    56   157    52    76    21   189    99   217    43   150    92   219   148   173   138   184   183   203    62   231   125    42    79    29   248    30    26   127    50     9    31   219   212   160   157   243    15    52   217     7   144    43   241    70    98   247   231   174   111    96    91   108    59   164   146    77   180   212   155   165    18   150   198   100   233   255   129    44   170   150   243   244   126   203   255   231    28    94    77    58   198   147    84   212   248    36    34   107   210    77    79    80   224    24   126    88   125   255    11   124   227    44   253   242   234    59   176   108   146   170   132    20   128   230   141   187    81   139    26   119    47   159     8   182    40    94   213   107   223    21   187    35     1    40   145   154    92   218   252    46   201   203    65    48    94   118   110     5   158   212    19   129     9    59   124    19   190   201    55   141   124   210    85   240    34   150    81   154    11     3   116   204    37    73    39   169   234    50   241   131    94     9   133     0   209   190   171   206    93   165   145   142   117   230    34   245   223   205   153   227   202     3   218    56   163   203   137    46   114    78   248   196   136    19   177   126    95   231   213   251   130    39    57    59   228   251    73    48     9   109    11   172   152   223   120   153   108   233    76   117   219     8     6   124    44     7   249   116    43   198    98    55   235    52    47   146   239    76   142    88    19    64   169   209   206   255   101    91   197    36   180   253    52    54    63   198    63   113    58    43   229   141    59     4   147    34   200     7   184   108   176   153    95    94    18   235   178   160    51    63   154   227    39   231    71   246   109    13   199   185   220   180    50   146    85   194   176   175   159   103   177    47   149   252   182    33   224   226     1   232   167    94    93   202    55    60   201   228   107   135   142    22   165   168   124   219   216    34   230   174   179    66    67    91    92   186    30    48     9   177   192   254   190   236    52    84   114   255     3    81   150   112   131    49   157    48   243   218    11   132    40    13    68   214   159    36   109   152   219    32   219   193   182    69    37   104   217   115    54   158    79    90     3   223   116   127     8    28   233   223   194    30   241   180    45   209    77   180   184    52   132   164    49   206    50    57   149   118   105    44    25   212   141   253   150    45   244    73   203    10   137   161   118    49   165   248   105   215    58    90    67   180    78    22   135   102   173   139    62    31    63    82   187    78    47     2   176   144    83    22   143    31   155     8   160    12   252   164    52   159   102   113    95   132    49   168   194   137    32   131   189   139    77   143   248    36    30   154   239   163   149    86     9   178   122     6   248    25   208   211   142    59    23    72    43   158   195   244   232   229   245   148    49   163    28    81    93   106    33   239   249    26   220    73    65   112   249   254   251    91   106   204   113    10    59    34   114   189   185   188   181   100   185    22   188   221   187   109   170    35    57   181   234   157   230   206   169    97   140    51   170   128   215   188    14    50   190   167    41   173    19    10    98   165    12    77    49    21    33   147    93    84   163   106   151   234    76   252    91   165   248   223   136    85   124   174    90   188   130   174    83    92   181   134    65    91   105    15   103    91    15    27   201   162    58    84   164    33   137    63     0    84     0    78   180    31   218    47    84    43    13    35   122   117   205    59    81   146    97    14];\r\nassert(isequal(mgf(mgfSeed,maskLen),mask))\r\n%%\r\nmgfSeed = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nmaskLen = 300;\r\nmask = [96   185   223   209   149    51   224   128   249   139    57   249   190    69   199   132    37    24    75   127    98    59   231   206    13    83    79   111   181   220   204   120    27   178   155   116   155    11   157   112    10   195   106     4   127   146   101   112   197    29    54    45    14    78    16   100     1   111   156    44   138   141   219   101   171     1   126   254    60    82   214    63    13    94   227   238    64   173    93   142     3   224    63    76     8   190   105     8    77   113   250   243   249    82    56   124   129   116   121   131   207   116    80   185    72   184   244   232   236   127    37   195   236   163   176   245    65    48   169   131    19    36   208   178   184   150   188    50   221    83   132   241    73   205    23     9    41    74    65   251    10    21   133   150   101    15    42   153   164   197   136    19   113   134   153   247    10   161   221   184   195   215   253   149   223    83   180   148   198     4    53   112   114    39    18   132   254   170   130    61     6   158   224   166    76   187   190   128    14   251   158   218   192    68    46   210   199   231   120    57   212    10   107     2    50    37   110    30    87    48     2   134    81   165   107    95   250   206    98    26    45   102   173    46    85   103   137     4   140   154   236   142   125   211    28   164    94    41     8    70   215    10    13   140   139    97   205    60   212   205    35   175   235   158    88   165    40    41   187   215    72   172    97   159   119    79    80    31   128   121   108    94   219   216    77   209   184   244    90   238   182   207   244    52   248     6   220   175   117   122   236   228   219    42    49   196   186    12    19    95];\r\nassert(isequal(mgf(mgfSeed,maskLen),mask))","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-09-06T22:10:21.000Z","updated_at":"2025-10-15T14:43:51.000Z","published_at":"2019-09-06T22:31:17.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate Mask Generation Function (MGF1) from PKCS #1 v2.2 standard (B.2.1) at below link. Input will be character array (mgfSeed) which will need to be converted to octet array using UTF-8 representation. Output must be octet array (uint8) of length, maskLen (input). Hashing must use SHA-1 (160 - 20 byte).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[mgfSeed = 'I like to swim.';%input\\nmaskLen = 20;%input\\nmask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44959,"title":"RSA encryption using public key ","description":"Encrypt the message text by converting to uint8 matrix using UTF-8 representation. Convert uint8 matrix to a large integer string. Use RSA encryption on the integer string given the public keys (n and e) and output the encrypted integer string. The public key (e) will always be fixed at 65537. No hashing or padding of the message is done.\r\n\r\nFor example:\r\n\r\n  message = 'I like to swim!';%given as input\r\n  integer_String = '379695297047669462525290688599911713';%calculated\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%given as input\r\ne= 65537;%fixed\r\noutput_String = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%output\r\n\r\nSee:\r\n\u003chttps://simple.wikipedia.org/wiki/RSA_algorithm\u003e\r\n","description_html":"\u003cp\u003eEncrypt the message text by converting to uint8 matrix using UTF-8 representation. Convert uint8 matrix to a large integer string. Use RSA encryption on the integer string given the public keys (n and e) and output the encrypted integer string. The public key (e) will always be fixed at 65537. No hashing or padding of the message is done.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003emessage = 'I like to swim!';%given as input\r\ninteger_String = '379695297047669462525290688599911713';%calculated\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%given as input\r\ne= 65537;%fixed\r\noutput_String = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%output\r\n\u003c/pre\u003e\u003cp\u003eSee: \u003ca href = \"https://simple.wikipedia.org/wiki/RSA_algorithm\"\u003ehttps://simple.wikipedia.org/wiki/RSA_algorithm\u003c/a\u003e\u003c/p\u003e","function_template":"function encrypted_message = RSA_Encrypt(message,n)\r\n  encrypted_message='14133';\r\nend","test_suite":"%%\r\nmessage = 'I like to swim!';\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';\r\nout = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';\r\nassert(isequal(RSA_Encrypt(message,n),out))\r\n%%\r\nmessage = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nn='44842008376687803367401704855862174057751658874412319214254366772513580664834338103711248053800336314605433363839051280089244765499067546768593375603554906634041005882836398715141891796137918851678901692978242458027064144613729242304549721699241688731628849316717564354846304644497408201649639245333007226999680183209765262168096747256549932760714835163829498814356014506466022681051474161134416048209239076204778228261950266231966892099194904195589855692846886804440024833800891898474520523721428667143505915995217245366095168045283186412220277535584022415882288464175935131208288146822299727657938865855853054174274144036081729604573534323903573564345990066095029031133576597298513883268061041004553754062342541175017746399640362184228727837219293246060058323563065371426108553463224921179093569734439828568435658070810483844709529476015493154462587917722806971578721201741643550136095893915598053953011321347017522943202801820158823344592288227452688958887872572522782675644714289349442555731461112275849176682816627205790162163242534462778708459909915826953853537650009043468930450287584181263070727575137424307931682948818963610116434419852585517456098152109913486868606969385133300794635427715727859479612757775192862801547635779921771426233897718528292667112148507798722127322607462037572360649156150337532940752245966765201596748120586383127825681873289878451591957019880886587602576426267683951317718936847177641679183717321862429721190212389237395890951104472937261743929446841800523276218816808066432194473964294708564511969507018959711475230849760902049071415838600456901108854663197095849833602808088094456341330276320302662577163562657750920481798540333412112880539002713127873625438212479154166226846436038698572615482646490520911334607730484144343834476612603467400722323562384577281087071440008144012534847478593412147312743274523095010025887231371129897419306984829625295595332434377173711414555784685658774002600022998291909172576630780759729269867715816511099791566815282862210319017784751883446582453959';\r\nout = '23055330962704323769878549529115024711681463755869375992447358448257597289666397997393945478297323372847937346015110864832142828615195632399869833059964395947034849804307978652470092440225822549097020437344501330227622390881049097656181781980124142659454562923055085607225529541369345564097544873012395850084756321027482195140106724706102857159831541577386517426252851135917933602432485339455137853480425755360413522537180403768732770990453717801905433194599201771294559164174484366213507079896512750859909040228686293902666244968559905065091421969981123917913807285202549025830873320919273470513619143052127674709353494599047667391749001044180280253098309127910967801244777547067797257847396027373615105278074126621948502699483945442597921239032762535839481741386676784123570880434889025648597593711911259097408384527597630246903648267481820555872340696607290773027177673329986283293168575528258578575033034179306629426942699054620008867304832513427178319015491321861291086200676826846740503213061372327825278234127270730394825241275398344604061667061892125034848354745243512927194104643800196788262228848172689053393410972717679060779374106225778531311917434399927265718394014531619654762559111657295163989321031700962115070401533540746801357628868609255941469541707984326602981168016264720519340003693219403163278843126513912057794102645161814569893320900148891952732032827189210372803453777673309727629845360314416264926243414888253428149538146304399700653423118791724424837155323935319171814705469113037576054893140065594406360362408167462563925199225169055130480445976569760198217276692195730775524801021060293503580957364539210146595506177369243830063105693396808209631409860229448190041996912370291877581261016834769083953407597967437841733812344230896457097759403613339974363380556576775192238298546579676296359906794868505900966056565863994904406875527092603782089107591766239203672780399852597928423220774857864301715176837587724591257928112610743311445186658958007825888475800717425136849205837547536117562642680';\r\nassert(isequal(RSA_Encrypt(message,n),out))\r\n%%\r\nmessage = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nn='2044371069952561243871813747701535503388267616657953475148898181142012590397809234167373308955772082860082985954286137615597515257087506574051530104475374974920093127841789408014496870693507622812332673504654584870100580476794800708440785082437228308551107726064054828640053321250498545183042994878498928173976370185712833904492317580152665428272199317847097773542066059565512439224992672101163367819';\r\nout = '99761240327251194937668282784881225946299704960682605372368300120848092908591455333889649815054891832920433772438140697229743047905660648016064750862552787515723449901585029566883857331537912668878918706229773460108043130645834201085405226084010413433457258525704626839479467337463012332940952234541291286602023412313079939518264986360860440514106228995186076871512459300140814669747884371890194124';\r\nassert(isequal(RSA_Encrypt(message,n),out))","published":true,"deleted":false,"likes_count":1,"comments_count":5,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":"2019-08-29T18:00:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-08-29T02:42:05.000Z","updated_at":"2025-10-15T14:57:07.000Z","published_at":"2019-08-29T02:52:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEncrypt the message text by converting to uint8 matrix using UTF-8 representation. Convert uint8 matrix to a large integer string. Use RSA encryption on the integer string given the public keys (n and e) and output the encrypted integer string. The public key (e) will always be fixed at 65537. No hashing or padding of the message is done.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[message = 'I like to swim!';%given as input\\ninteger_String = '379695297047669462525290688599911713';%calculated\\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%given as input\\ne= 65537;%fixed\\noutput_String = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://simple.wikipedia.org/wiki/RSA_algorithm\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://simple.wikipedia.org/wiki/RSA_algorithm\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45213,"title":"AES-256 KeyExpansion()","description":"Given a 32-byte hexadecimal character array representing the AES-256 input key, execute the AES-256 algorithm, KeyExpansion() and output the xth (input) key-word of this 60-word sequence as a 4x2 hexadecimal array. You will need the SubBytes() function done in one of my previous Cody problems.\r\n\r\nRefer to this link: \u003chttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003e\r\n\r\nFor example:\r\n\r\n  key='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\r\n  x=58;%want key-word number 58 out of 60\r\n  w=['d0';'eb';'7c';'8a'];%58th key-word","description_html":"\u003cp\u003eGiven a 32-byte hexadecimal character array representing the AES-256 input key, execute the AES-256 algorithm, KeyExpansion() and output the xth (input) key-word of this 60-word sequence as a 4x2 hexadecimal array. You will need the SubBytes() function done in one of my previous Cody problems.\u003c/p\u003e\u003cp\u003eRefer to this link: \u003ca href = \"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\"\u003ehttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ekey='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\r\nx=58;%want key-word number 58 out of 60\r\nw=['d0';'eb';'7c';'8a'];%58th key-word\r\n\u003c/pre\u003e","function_template":"function w = KeyExpansion(key,x)\r\n  w = key;\r\nend","test_suite":"%%\r\nkey='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\r\nx=58;\r\nw=['d0';'eb';'7c';'8a'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='4b6b0490163a5b44345675ba437aec16eee63eee26643e0d2fe1f51eb8e0ca0b';\r\nx=31\r\nw=['da';'8d';'75';'fb'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='c0ad28b4cb90e11f5420fbfe9042b10f79e5a3adc1ca2fdb6c3e034a4ee79d4b';\r\nx=60;\r\nw=['38';'57';'bb';'18'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='b8b6426ab2dedb79f812fc5c2edb81e5a3fd5ef58a9dcbe728fcb93e36352969';\r\nx=10;\r\nw=['9d';'cd';'60';'16'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=7;\r\nw=['48';'d9';'78';'d8'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=57;\r\nw=['e3';'7d';'c6';'78'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=58;\r\nw=['cd';'9a';'06';'35'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=59;\r\nw=['1e';'2b';'6e';'33'];\r\nassert(isequal(KeyExpansion(key,x),w))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-22T00:25:14.000Z","updated_at":"2025-10-11T16:12:13.000Z","published_at":"2019-11-22T01:37:11.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a 32-byte hexadecimal character array representing the AES-256 input key, execute the AES-256 algorithm, KeyExpansion() and output the xth (input) key-word of this 60-word sequence as a 4x2 hexadecimal array. You will need the SubBytes() function done in one of my previous Cody problems.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRefer to this link:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[key='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\\nx=58;%want key-word number 58 out of 60\\nw=['d0';'eb';'7c';'8a'];%58th key-word]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44964,"title":"Optimal Asymmetric Encryption Padding of message for RSA Cryptography ","description":"EME-OAEP encoding of input message using a Feistel network with SHA-1 hashing within the mask generation function (MGF1) (see problem 44963/below link 7.1.1 page 18). Inputs will include message (M), label (L), a random seed (seed) array of octets of length 20 (needed such that outputs can be compared), and output length (k). Output (EM) array will be an array of octets of length, k. Hash length will always be 20 for SHA-1 (160-20 bytes). The character length of input message will never exceed k-42.\r\n\r\nFor example:\r\n\r\n  M = 'I like to swim.';%input\r\n  L = 'abcdefghijklmnopqrstuvwxyz';%input\r\n  seed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];%input\r\n  k = 100;%input\r\n  EM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\r\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\r\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\r\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\r\n148,12,50,108,248,32,94];%output\r\n\r\n\u003chttps://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 356px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 178px; transform-origin: 407px 178px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eEME-OAEP encoding of input message using a Feistel network with SHA-1 hashing and mask generation function (MGF1) (see problem 44963/below link, section 9.1.1.1 (figure 1 shows the encoding process)). Inputs will include message (M), label (L), a random seed (seed) array of octets of length 20 (needed such that outputs can be compared), and output length (k). Output (EM) array will be an array of octets of length, k. Hash length will always be 20 from SHA-1 (160-20 bytes). The character length of input message will never exceed k-42.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 180px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 90px; transform-origin: 404px 90px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eM = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'I like to swim.'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eL = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'abcdefghijklmnopqrstuvwxyz'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ek = 100;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e148,12,50,108,248,32,94];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%output\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function EM = EMEOAEPencoding(M,L,seed,k)\r\n  EM = []%octet array of length k\r\nend","test_suite":"%%\r\nM = 'I like to swim.';\r\nL = 'abcdefghijklmnopqrstuvwxyz';\r\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\r\nk = 100;\r\nEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,148,12,50,108,248,32,94];\r\nassert(isequal(EMEOAEPencoding(M,L,seed,k),EM))\r\n%%\r\nM = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nL = '';\r\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\r\nk = 300;\r\nEM = [0   145   194    62    62   111    86   188    50    37   165   231    16    42    25    79   223   177   117   187   135   200   203   136   184   133    38   175    66    35   142   212   144   116    66    37   151     8   190   218    29   238   213    11   189   225    88    83   218   175   183    98    58   237    89    80   123    64    40   154   137    44    13   186    97   133    92    11   228    32   100   188    61    37   150   198   178    73   252    17   133   233    68    13    39    99     3   239   108   106   202   227   127   142    79    34   126   244    41    92   240     8   127   153   251    25    82    79   247    92   187    51    84    38   104   240    52   209   144   160   144   119   131    67   128   116    98   132    51    79     8   114    69   202    80   243   194    61    17    33   225   232   173     5   153   230    32   155    34    62    72     2   211   212   227     5   115   217    33   189    21   170    51   190   217   119   148    73   209   109   114    90   104   237   168    60   144   120   191     7   186     8   205   111   192   249   192   197    34   225   209   153   234     5    27   165    82    42   132   167   158    64   218   239    71    49   166    27    37     9   154     2   255   193    72    75     7   121   121   240    74   116   185    58    79   106    68    14    17    49    68    96   160     2    75    15   122   144    36    47   230   112    39   221    21   141   251   178    10   215   180   230   184   189   112   108   187    83    94   157    69   140   201    40   158   119    28   159   116   196   206   112    91   141    68   122   113   183    92   111    44   149   187   223   179   157    29    79   180   231    38   122   231    82    98    42    69    14   162    53];\r\nassert(isequal(EMEOAEPencoding(M,L,seed,k),EM))\r\n%%\r\nM = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nL = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\r\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\r\nk = 825;\r\nEM = [0    85    82   177   212   151     6   148    36   245   178   209   163    30    35   103   231   155   104   206    51   230   201    47   178   114   199    15   172   217   175    58    48   240   133     0   186   218    10   200    31   238   213    10   237   132    55    35   182   202   151    21    82   130   121    35    14    35    75   255   236    72    45   210     0   243    57    43   137    79     9   217    83    81   227   171   156   105   168   121   224   201    41    98    85     6    35   155     4    15   179   195    12   251    44    65    27   145    77   112   208   124    23   252   219   116    61    61   146   124   207    91    49    95    72   135    85   191   228   128   228    24   163    48   245    23     1   225    86    43    40    19    43   174   112   135   170    88    49    76   142   154   200    37   237   142    69   226     2    88    33   108   183   244   130    37     4   184    88   157    97   197    19   205   172    20   247    44   180     9    92   122    59   132   197    85   252    25   205   107   195    36   237    24   168   156   174   229    81   142   188   252   133   107   126   133    59    89   164   193   255    41   182   134    41    86   138    59    81    97   255    34   139   164    38    47    98    23    26   137   106    29   202    26    59     5   100   105   116    69   100    15   206    34    42    47    30   255    83    65   145    17    85   185    53   254   139   219   120   182   216   198   204   213    17    24   155    48    63   243   101   233   191    77   240    87   126   250    23   171   163    21   123   236   100     9    20   219    58    66    74   224   215   185   218   241   113    38   218   128     6    10   149    61    18    66    32   109   219    27   107   176    90   163   116    99    71    16   108    89   192   253   121   121    76   157   101   157   217    51    53   248   195    95    93   183    71    29   199     2   182    31   120    35   167    44   189   160     2   154   234   162   113   204    18   138    81   155    86   122   147    44    23   181    90   135    49   235    41   194    82   181    31    45   131    78   127   198   121   132    49     6   186    66   157   159    79   110   184   152    83   107    73    61    22    86   160   156   200   177    64   217    32   251   102     4   165   143   254   215   165   224   110    76    57    69    13   198   180   106   236    11    39   238     0   220    63   109   239   190    19    85    92    23    28   183   233    72    88   193     8   101   127   214   171     7    94   156   148   220    40    84    44   149     7   245   165   150   197    27    93   255   146    15   132   133   174   208     4   156   246    12    37    50    78    85    95   212   198    41    22   138   214   135   145   197   137   114   172   128    48   126   202   198     0    35    15    37   127     1    34    44   164    46   131    12    87   254     9   210   140    50    85   180   173   121    24    14   192   237    75   224    91   242   205   155     8   136    51    38   161     6   129   234    36     1    56   251    11     6    73    36    74   230    95   174    47    94    53   106   142    71   123    88    32    41     7   108    41   101    40   120   254   196    47   251    83   224   181   114   255   127    56     6   182   182   153   244   162   214   115   183   162    69    47   174   112    68    89   110   180    43    47   159   195   123    73   230   230   186   204   129   110   234   218   152    57   154   232    91    68   237   204   222   179   175   192   249     1   128     5   180    93    29    14    97   175   138   175   221   223   219    62    93   142    51   123   194    90     6   215    32   181    60    48    92   100   114    28   164    71   110   244   129   190   125    27   156   223   133     7   128    55   127    93     3    21    66    38   184    50    52     6   164   175    17   255   103    42    28   126    66    19   149    66     6   234   170   194   104    85    42   166   171   117   101    33    74    35   181    46   242   102   192   226   183   132   223   154    97   142   119   107     6    98    93   129   255   247   144   159    12   245   161   179    28     1   228    24    38   147    55   148    10   247   224   154   201   241    32    53    23   219    52     0   124    35    47    36    89   180    68    57   183   240    94   235    86   152   105    26   113    72    38    83   194   138    16    45   187    50   207   192   151    54    80   108   139   211   116   186   176    20   250    32   117   237   241   239   224   147   110    22   190    71    59    47    97     8   144   236   102     8   216   238   225    40   212   181   238   106   223    38   121   175    55    54   194   114   234   213    89    36   150   177   249    96   235    51    12   205    84   247   160    76];\r\nassert(isequal(EMEOAEPencoding(M,L,seed,k),EM))","published":true,"deleted":false,"likes_count":1,"comments_count":12,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-09-06T23:39:52.000Z","updated_at":"2025-10-15T14:05:18.000Z","published_at":"2019-09-07T00:59:36.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEME-OAEP encoding of input message using a Feistel network with SHA-1 hashing and mask generation function (MGF1) (see problem 44963/below link, section 9.1.1.1 (figure 1 shows the encoding process)). Inputs will include message (M), label (L), a random seed (seed) array of octets of length 20 (needed such that outputs can be compared), and output length (k). Output (EM) array will be an array of octets of length, k. Hash length will always be 20 from SHA-1 (160-20 bytes). The character length of input message will never exceed k-42.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[M = 'I like to swim.';%input\\nL = 'abcdefghijklmnopqrstuvwxyz';%input\\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];%input\\nk = 100;%input\\nEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\\n148,12,50,108,248,32,94];%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44956,"title":"Determine RSA keys (public and private) given two prime number character strings (p and q)","description":"Given two prime number character strings (p and q), generate the RSA public and private keys (n and d) with e = 65537. The more difficult part is doing this without the use of symbolic numbers.\r\nExample: p = '3355335697481001330501721', q = '5955344080483688912855719'\r\nn='19982178584029090861856118769095354822153154192399'\r\nd='3270348772331599380262578849367006078599068947553'\r\n\r\n\u003chttps://simple.wikipedia.org/wiki/RSA_algorithm\u003e\r\n\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eGiven two prime number character strings (p and q), generate the RSA public and private keys (n and d) with e = 65537. The more difficult part is doing this without the use of symbolic numbers.\r\nExample: p = '3355335697481001330501721', q = '5955344080483688912855719'\r\nn='19982178584029090861856118769095354822153154192399'\r\nd='3270348772331599380262578849367006078599068947553'\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://simple.wikipedia.org/wiki/RSA_algorithm\"\u003ehttps://simple.wikipedia.org/wiki/RSA_algorithm\u003c/a\u003e\u003c/p\u003e","function_template":"function [n,d] = keyGeneration(p,q)\r\n  n = p;\r\n  d = q;\r\nend","test_suite":"%%\r\np = '3355335697481001330501721';\r\nq = '5955344080483688912855719';\r\nn='19982178584029090861856118769095354822153154192399';\r\nd='3270348772331599380262578849367006078599068947553';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '813610636673';\r\nq = '1605983302589';\r\nn='1306645097305643499246397';\r\nd='355984378478555057894913';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '67979691391330950855242581938207942707483223433259';\r\nq = '6153843674264879356192291854148321819411378704398479';\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '9889977922600049892469466917642800243744956526655686322206918503863571743809023708648966023469645149';\r\nq = '2476454822450020555811121392457617785385805217059253393679351596046272567110905233495088857069108236299';\r\nn = '24492083520347129695334786995557239882540750861618765872694983337614252441655470479409598244691513160097634784088025768219041142794039842531021683737585081956313858395523050254392582005967309810771063551';\r\nd = '7043758337908398316945695794623843894382227935971901356005844728128437829322707899292187736941661046350269216062193211515498221491327821445579367736374708711769362662280124297131956999441862850977388289';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '26892754546730837119898059580995437039544399594421875855251066246511044160199048288603963625982639028058714345196159764252398791569637860905138287322706679328840515337572608690956308136959236074835599';\r\nq = '76019400184540822543696224086250845563040709795227937154720461468348727220343229834542918037619525984430713380822472295398107810565069813256377730791194881206750953165713183208458761595898204049235781';\r\nn='2044371069952561243871813747701535503388267616657953475148898181142012590397809234167373308955772082860082985954286137615597515257087506574051530104475374974920093127841789408014496870693507622812332673504654584870100580476794800708440785082437228308551107726064054828640053321250498545183042994878498928173976370185712833904492317580152665428272199317847097773542066059565512439224992672101163367819';\r\nd='131358569595346680469722564224349085322306406056832660693226883146757023027681686453130430199929142940992255578581548217026735077095312421736286269892515739496597527524021166625708322359741224036234988705082882699895245449017415856831226734459122764117157172961113990706104659539690141481103935528273973382371183154438463086325519326121228923730136467766036183357672350586091588640276470994058874793';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))","published":true,"deleted":false,"likes_count":3,"comments_count":10,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":"2019-08-28T22:45:19.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-08-26T02:38:07.000Z","updated_at":"2026-03-04T16:55:19.000Z","published_at":"2019-08-26T02:45:23.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two prime number character strings (p and q), generate the RSA public and private keys (n and d) with e = 65537. The more difficult part is doing this without the use of symbolic numbers. Example: p = '3355335697481001330501721', q = '5955344080483688912855719' n='19982178584029090861856118769095354822153154192399' d='3270348772331599380262578849367006078599068947553'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://simple.wikipedia.org/wiki/RSA_algorithm\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://simple.wikipedia.org/wiki/RSA_algorithm\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44383,"title":"Code breaker, Part III:  Operation Xiangliu","description":"You have been tasked with decoding several batches of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary _between_ (not within) batches — also, here you need to decode, not encode.  \r\n\r\nThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation.  A few decoding options are at your organisation's disposal:  \r\n\r\n# Test the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\r\n# Test the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g. \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351 \"Operation Phoenix\"\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.  \r\n# Test the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\r\n\r\nThe *third option* will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.  \r\n\r\nYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \"to be\", rather than the various inflected forms such as \"am\", \"is\", \"are\") like those based on the \u003chttps://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language OEC\u003e or \u003chttps://www.wordfrequency.info/free.asp?s=y COCA\u003e, and after setting aside \u003chttp://world-english.org/english500.htm another list\u003e you finally choose the \u003chttp://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf list based on the BNC\u003e as the most reliable, and will use the first 100 words on that list.  \r\nThis list will be available for you to access as an input variable, |bncWordlist|, to your function. Note: (i) some entries on the list are morphemes (e.g. \"\u0026#x200A;n't\u0026#x200A;\" and \"\u0026#x200A;'s\u0026#x200A;\") rather than words;  (ii) some entries appear more than once (representing different grammatical word classes).  Of course, in the original messages any capitalisation might be used.  \r\n\r\nYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in |bncWordlist|.  Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude;  matching three-twentieths would be 50% certitude, and so on.  Certitude shall be reported as a percentage, rounded _up_ to the nearest integer, not greater than 100.  You need to maximise your certitude for each batch by appropriate choice of the shifting parameter.   If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e: \u0026nbsp; (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e] (usually scalar, but may be column vector); \u0026nbsp; (2) the decoded messages [as a \u003chttp://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta cell array\u003e (containing \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e)] (usually an array with a single row, but occasionally with multiple rows); \u0026nbsp; (3) your 'certitude' in the decoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e] (always scalar).  \r\nThe name of the structure array shall be |s|, with respective fields |shift|, |message|, and |certitude|.  \r\n\r\n*EXAMPLE 1*\r\n\r\nSuppose the batch contained two encoded messages — _\"Vomftt qvstvfe, pqfo op eppst.\"_ and _\"Ffmt dbo ljmm, opu pomz xpvoe.\"_ (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  \r\nThus the original messages would have been:  _\"Unless pursued, open no doors.\"_ and _\"Eels can kill, not only wound.\"_ .  Twelve of the 51 characters have been matched:  \"no\", \"can\", \"not\", and \"only\".  \r\n\r\nThe correct answer would therefore comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\r\n  s.certitude = uint8(79)\r\n\r\n*EXAMPLE 2*\r\n\r\nSuppose the batch contained one encoded message — _\"Oa oqvvq'u cnycau dggp: \"Ctu itcvkc ctvku\".\"_ (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied.  In that case A→C, B→D, ..., Y→A, and Z→B;  similarly, a→c, b→d, ..., y→a, and z→b.  \r\nThus the original message would have been:  _\"My motto's always been: \"Ars gratia artis\".\"_ .  Eight of the 37 characters have been matched: \"My\", \"\u0026#x200A;'s\u0026#x200A;\", and \"been\".  Note carefully that:  \"\u0026#x200A;'s\u0026#x200A;\" should only be matched once;  \"to\" (in motto), \"be\" (in been), \"at\" (in gratia), \"is\" (in artis) and \"a\" (passim) should _not_ be matched at all;  and \"\u0026#x200A;'\u0026#x200A;\" will only ever be used as an apostrophe (never as a quotation mark).  \r\n\r\nThe correct answer would therefore comprise:  \r\n\r\n  s.shift = uint8(2)  \r\n  s.message = {'My motto''s always been: \"Ars gratia artis\".'}\r\n  s.certitude = uint8(73)\r\n\r\nIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.  \r\n\r\n|Note:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".  \r\n\r\n----------\r\n\r\nPrevious problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44356 Operation Orthos\u003e.  Next problem:  TBA.","description_html":"\u003cp\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary \u003ci\u003ebetween\u003c/i\u003e (not within) batches — also, here you need to decode, not encode.\u003c/p\u003e\u003cp\u003eThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation.  A few decoding options are at your organisation's disposal:\u003c/p\u003e\u003col\u003e\u003cli\u003eTest the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\u003c/li\u003e\u003cli\u003eTest the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g. \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351\"\u003e\"Operation Phoenix\"\u003c/a\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.\u003c/li\u003e\u003cli\u003eTest the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eThe \u003cb\u003ethird option\u003c/b\u003e will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.\u003c/p\u003e\u003cp\u003eYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \"to be\", rather than the various inflected forms such as \"am\", \"is\", \"are\") like those based on the \u003ca href = \"https://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language\"\u003eOEC\u003c/a\u003e or \u003ca href = \"https://www.wordfrequency.info/free.asp?s=y\"\u003eCOCA\u003c/a\u003e, and after setting aside \u003ca href = \"http://world-english.org/english500.htm\"\u003eanother list\u003c/a\u003e you finally choose the \u003ca href = \"http://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf\"\u003elist based on the BNC\u003c/a\u003e as the most reliable, and will use the first 100 words on that list.  \r\nThis list will be available for you to access as an input variable, \u003ctt\u003ebncWordlist\u003c/tt\u003e, to your function. Note: (i) some entries on the list are morphemes (e.g. \"\u0026#x200A;n't\u0026#x200A;\" and \"\u0026#x200A;'s\u0026#x200A;\") rather than words;  (ii) some entries appear more than once (representing different grammatical word classes).  Of course, in the original messages any capitalisation might be used.\u003c/p\u003e\u003cp\u003eYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in \u003ctt\u003ebncWordlist\u003c/tt\u003e.  Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude;  matching three-twentieths would be 50% certitude, and so on.  Certitude shall be reported as a percentage, rounded \u003ci\u003eup\u003c/i\u003e to the nearest integer, not greater than 100.  You need to maximise your certitude for each batch by appropriate choice of the shifting parameter.   If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e: \u0026nbsp; (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e] (usually scalar, but may be column vector); \u0026nbsp; (2) the decoded messages [as a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\"\u003ecell array\u003c/a\u003e (containing \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e)] (usually an array with a single row, but occasionally with multiple rows); \u0026nbsp; (3) your 'certitude' in the decoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e] (always scalar).  \r\nThe name of the structure array shall be \u003ctt\u003es\u003c/tt\u003e, with respective fields \u003ctt\u003eshift\u003c/tt\u003e, \u003ctt\u003emessage\u003c/tt\u003e, and \u003ctt\u003ecertitude\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003e\u003cb\u003eEXAMPLE 1\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSuppose the batch contained two encoded messages — \u003ci\u003e\"Vomftt qvstvfe, pqfo op eppst.\"\u003c/i\u003e and \u003ci\u003e\"Ffmt dbo ljmm, opu pomz xpvoe.\"\u003c/i\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  \r\nThus the original messages would have been:  \u003ci\u003e\"Unless pursued, open no doors.\"\u003c/i\u003e and \u003ci\u003e\"Eels can kill, not only wound.\"\u003c/i\u003e .  Twelve of the 51 characters have been matched:  \"no\", \"can\", \"not\", and \"only\".\u003c/p\u003e\u003cp\u003eThe correct answer would therefore comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\r\ns.certitude = uint8(79)\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eEXAMPLE 2\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSuppose the batch contained one encoded message — \u003ci\u003e\"Oa oqvvq'u cnycau dggp: \"Ctu itcvkc ctvku\".\"\u003c/i\u003e (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied.  In that case A→C, B→D, ..., Y→A, and Z→B;  similarly, a→c, b→d, ..., y→a, and z→b.  \r\nThus the original message would have been:  \u003ci\u003e\"My motto's always been: \"Ars gratia artis\".\"\u003c/i\u003e .  Eight of the 37 characters have been matched: \"My\", \"\u0026#x200A;'s\u0026#x200A;\", and \"been\".  Note carefully that:  \"\u0026#x200A;'s\u0026#x200A;\" should only be matched once;  \"to\" (in motto), \"be\" (in been), \"at\" (in gratia), \"is\" (in artis) and \"a\" (passim) should \u003ci\u003enot\u003c/i\u003e be matched at all;  and \"\u0026#x200A;'\u0026#x200A;\" will only ever be used as an apostrophe (never as a quotation mark).\u003c/p\u003e\u003cp\u003eThe correct answer would therefore comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(2)  \r\ns.message = {'My motto''s always been: \"Ars gratia artis\".'}\r\ns.certitude = uint8(73)\r\n\u003c/pre\u003e\u003cp\u003eIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003ePrevious problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44356\"\u003eOperation Orthos\u003c/a\u003e.  Next problem:  TBA.\u003c/p\u003e","function_template":"% Comments are nice, aren't they....\r\nfunction s = decode(x, bncWordlist)\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions.\r\n% The assessment of your submission may therefore change over time.  \r\n\r\nglobal bncWordlist\r\nbncWordlist = {'the', 'of', 'and', 'a', 'in', 'to', 'it', 'is', 'to', 'was', ...\r\n    'I', 'for', 'that', 'you', 'he', 'be', 'with', 'on', 'by', 'at', ...\r\n    'have', 'are', 'not', 'this', '''s', 'but', 'had', 'they', 'his', ...\r\n    'from', 'she', 'that', 'which', 'or', 'we', '''s', 'an', 'n''t', 'were', ...\r\n    'as', 'do', 'been', 'their', 'has', 'would', 'there', 'what', 'will', 'all', ...\r\n    'if', 'can', 'her', 'said', 'who', 'one', 'so', 'up', 'as', 'them', 'some', ...\r\n    'when', 'could', 'him', 'into', 'its', 'then', 'two', 'out', 'time', ...\r\n    'my', 'about', 'did', 'your', 'now', 'me', 'no', 'other', 'only', 'just', ...\r\n    'more', 'these', 'also', 'people', 'know', 'any', 'first', 'see', 'very', 'new', ...\r\n    'may', 'well', 'should', 'her', 'like', 'than', 'how', 'get', 'way', 'one', 'our'};\r\n\r\n\r\n%% Anti-hacking\r\n% EDIT (2019-07-02). Anti-hacking provision\r\n% Ensure only builtin functions will be called.\r\n! rm -v fileread.m\r\n! rm -v assert.m\r\n% END EDIT (2019-07-02)\r\n% EDIT (2018-06-18).  Anti-hacking provision\r\nRE = regexp(fileread('decode.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'assert', 'freepass', 'tic'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any(  cellfun( @(z) ismember(z, tabooWords), RE )  ), msg)\r\n\r\nfor j = 1 : randi(10)\r\n    decode({'Pizza for dinner.'}, {'mozzarella', 'mushrooms'});\r\nend;\r\n% END EDIT (2018-06-18)\r\n\r\n\r\n%% Test 1\r\nglobal bncWordlist\r\nx =                 {'Vomftt qvstvfe, pqfo op eppst.', 'Ffmt dbo ljmm, opu pomz xpvoe.'};\r\ns_correct.shift = uint8(1);\r\ns_correct.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'};\r\ns_correct.certitude = uint8(79);\r\ns = decode(x, bncWordlist);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.' )\r\nassert( isequal(s.message{1}, s_correct.message{1}), 'Wrong message{1}.' )\r\nassert( isequal(s.message{2}, s_correct.message{2}), 'Wrong message{2}.' )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.' )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.' )\r\nassert( isequal(s, s_correct), 'Wrong s.' )\r\nassert( isequal(class(s.shift), 'uint8'), 'Wrong class.' )\r\nassert( isequal(class(s.message), 'cell'), 'Wrong class.'  )\r\nassert( isequal(class(s.message{1}), 'char'), 'Wrong class.'  )\r\nassert( isequal(class(s.certitude), 'uint8'), 'Wrong class.'  )\r\n\r\n\r\n%% Test 2\r\nglobal bncWordlist\r\nx =                 {'Doo zduiduh lv edvhg rq ghfhswlrq.', ...\r\n    'Khqfh, zkhq deoh wr dwwdfn, zh pxvw vhhp xqdeoh;  zkhq xvlqj rxu irufhv, zh pxvw vhhp lqdfwlyh;  zkhq zh duh qhdu, zh pxvw pdnh wkh hqhpb eholhyh zh duh idu dzdb; zkhq idu dzdb, zh pxvw pdnh klp eholhyh zh duh qhdu.'};\r\ns_correct.shift = uint8(3);\r\ns_correct.message = {'All warfare is based on deception.', ...\r\n    'Hence, when able to attack, we must seem unable;  when using our forces, we must seem inactive;  when we are near, we must make the enemy believe we are far away; when far away, we must make him believe we are near.'};\r\ns_correct.certitude = uint8(95);\r\ns = decode(x, bncWordlist);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 3\r\nglobal bncWordlist\r\nx =                 {'Elia lrq yxfqp ql bkqfzb qeb bkbjv.  Cbfdk afploabo, xka zorpe efj.', ...\r\n    'Fc eb fp pbzrob xq xii mlfkqp, yb mobmxoba clo efj.  Fc eb fp fk prmboflo pqobkdqe, bsxab efj.'};\r\ns_correct.shift = uint8(23);\r\ns_correct.message = {'Hold out baits to entice the enemy.  Feign disorder, and crush him.', ...\r\n    'If he is secure at all points, be prepared for him.  If he is in superior strength, evade him.'};\r\ns_correct.certitude = uint8(100);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 4\r\nglobal bncWordlist\r\nx =                 {'Ax qgmj ghhgfwfl ak gx uzgdwjau lwehwj, kwwc lg ajjalslw zae.  Hjwlwfv lg tw owsc, lzsl zw esq yjgo sjjgysfl.', ...\r\n    'Ax zw ak lscafy zak wskw, yanw zae fg jwkl.', ...\r\n    'Ax zak xgjuwk sjw mfalwv, kwhsjslw lzwe.', ...\r\n    'Sllsuc zae ozwjw zw ak mfhjwhsjwv, shhwsj ozwjw qgm sjw fgl wphwulwv.'};\r\ns_correct.shift = uint8(18);\r\ns_correct.message = {'If your opponent is of choleric temper, seek to irritate him.  Pretend to be weak, that he may grow arrogant.', ...\r\n    'If he is taking his ease, give him no rest.', ...\r\n    'If his forces are united, separate them.', ...\r\n    'Attack him where he is unprepared, appear where you are not expected.'};\r\ns_correct.certitude = uint8(100);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 5\r\nglobal bncWordlist\r\nx =                 {'Aes cèwo vo foxd bémyvdo vo dowzy', ...\r\n    'Yx wo dbksdo no dbkîdbo aekxn to dbksdo no vk népksdo ne csvoxmo / Vo csvoxmo ocd n''yb, wksc t''ks mryscs vk mknoxmo', ... \r\n    'Mrkaeo wyd, mrkaeo zrbkco nsdc kfom owzrkco / Pksd no Mvkeno WM, vo mywwkxny no vk zrbkco', ...\r\n    'Mkb t''cesc ex WM n''kddkaeo, ckxc dsmc, kedroxdsaeo zkc ox dym / Zbêd à pbkzzob ceb vo lokd zyeb vo wyefowoxd rsz-ryz', ...\r\n    'Ne bkz n''kddkaeo aes pbkzzo, ézkdo, wkdbkaeo od zkdkdbkaeo / Zvec no ckxq de mvkaeoc, t''cesc WM noc Mkbzkdoc', ...\r\n    'Vo zénkqyqeo ox fyqeo ke xyw no myno Cyvkkb ye Mvkeno WM / Do zbyzyco n''émyedob moms / Ae''yx ézovvo voc fyiovvoc, nèc ae''yx cyxxo voc myxcyxxoc'};\r\ns_correct.shift = uint8([0 21]');\r\n% TIP:  The original message was not English!\r\ns_correct.message(1, :) = {'Aes cèwo vo foxd bémyvdo vo dowzy', ... \r\n    'Yx wo dbksdo no dbkîdbo aekxn to dbksdo no vk népksdo ne csvoxmo / Vo csvoxmo ocd n''yb, wksc t''ks mryscs vk mknoxmo', ... \r\n    'Mrkaeo wyd, mrkaeo zrbkco nsdc kfom owzrkco / Pksd no Mvkeno WM, vo mywwkxny no vk zrbkco', ... \r\n    'Mkb t''cesc ex WM n''kddkaeo, ckxc dsmc, kedroxdsaeo zkc ox dym / Zbêd à pbkzzob ceb vo lokd zyeb vo wyefowoxd rsz-ryz', ... \r\n    'Ne bkz n''kddkaeo aes pbkzzo, ézkdo, wkdbkaeo od zkdkdbkaeo / Zvec no ckxq de mvkaeoc, t''cesc WM noc Mkbzkdoc', ... \r\n    'Vo zénkqyqeo ox fyqeo ke xyw no myno Cyvkkb ye Mvkeno WM / Do zbyzyco n''émyedob moms / Ae''yx ézovvo voc fyiovvoc, nèc ae''yx cyxxo voc myxcyxxoc'}\r\ns_correct.message(2, :) = {'Fjx hèbt at ktci gérdait at itbed', ... \r\n    'Dc bt igpxit st igpîigt fjpcs yt igpxit st ap séupxit sj hxatcrt / At hxatcrt thi s''dg, bpxh y''px rwdxhx ap rpstcrt', ... \r\n    'Rwpfjt bdi, rwpfjt ewgpht sxih pktr tbewpht / Upxi st Rapjst BR, at rdbbpcsd st ap ewgpht', ... \r\n    'Rpg y''hjxh jc BR s''piipfjt, hpch ixrh, pjiwtcixfjt eph tc idr / Egêi à ugpeetg hjg at qtpi edjg at bdjktbtci wxe-wde', ... \r\n    'Sj gpe s''piipfjt fjx ugpeet, éepit, bpigpfjt ti epipigpfjt / Eajh st hpcv ij rapfjth, y''hjxh BR sth Rpgepith', ... \r\n    'At eéspvdvjt tc kdvjt pj cdb st rdst Hdappg dj Rapjst BR / It egdedht s''érdjitg rtrx / Fj''dc éetaat ath kdntaath, sèh fj''dc hdcct ath rdchdccth'}\r\ns_correct.certitude = uint8(11);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 6\r\nglobal bncWordlist\r\nx =                 {'Brvdujcnm mrbxamna yxbcdujcnb ynaonlc mrblryurwn;  brvdujcnm onja yxbcdujcnb lxdajpn;  brvdujcnm fnjtwnbb yxbcdujcnb bcanwpcq.' ...\r\n    'X mrerwn jac xo bdkcunch jwm bnlanlh!'};\r\ns_correct.shift = uint8(9);\r\ns_correct.message = {'Simulated disorder postulates perfect discipline;  simulated fear postulates courage;  simulated weakness postulates strength.' ...\r\n    'O divine art of subtlety and secrecy!'};\r\ns_correct.certitude = uint8(12);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 7\r\nglobal bncWordlist\r\nx =                 {'Nv treefk vekvi zekf rcczretv nzky evzxysfizex gizetvj lekzc nv riv rthlrzekvu nzky kyvzi uvjzxej.', ... \r\n    'Nv riv efk wzk kf cvru re ridp fe kyv drity lecvjj nv riv wrdzczri nzky kyv wrtv fw kyv tflekip — zkj dflekrzej reu wfivjkj, zkj gzkwrccj reu givtzgztvj, zkj drijyvj reu jnrdgj.', ... \r\n    'Nv jyrcc sv lerscv kf klie erklirc rumrekrxvj kf rttflek lecvjj nv drbv ljv fw cftrc xlzuvj.'};\r\ns_correct.shift = uint8(17);\r\ns_correct.message = {'We cannot enter into alliance with neighboring princes until we are acquainted with their designs.', ...  \r\n    'We are not fit to lead an army on the march unless we are familiar with the face of the country — its mountains and forests, its pitfalls and precipices, its marshes and swamps.', ...  \r\n    'We shall be unable to turn natural advantages to account unless we make use of local guides.'};\r\ns_correct.certitude = uint8(97);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 8\r\nglobal bncWordlist\r\nx =                 {'Oa oqvvq''u cnycau dggp: \"Ctu itcvkc ctvku\".'};\r\ns_correct.shift = uint8(2);\r\ns_correct.message = {'My motto''s always been: \"Ars gratia artis\".'};\r\ns_correct.certitude = uint8(73);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 9\r\nglobal bncWordlist\r\nx =                 {'Bestow rewards without regard 2 rule;  issue orders without regard 2 previous arrangements', ...\r\n    '\"Let advance bee richly rewarded \u0026 retreat bee heavily punished.\"', ...\r\n    ' Qwertyuiop''asdfghjkl.   Zxcvbnm-0123456789 = pass. ', ...\r\n    'αβγδ — persimon–apricot hybrid.', ...\r\n    'aIanasatbebydoheifinisitmemynoofonor''ssotoupweallandanyarebutcandidforgethadhasherhimhishowitsmaynewnotnown''toneouroutseeshethetwowaswaywhoyoualsobeenfromhaveintojustknowlikemoreonlysaidsomethanthatthemthentheythistimeverywellwerewhatwhenwillwithyouraboutcouldfirstothertheirtherethesewhichwouldpeopleshould'};\r\ns_correct.shift = uint8(0);\r\ns_correct.message = x;\r\ns_correct.certitude = uint8(0);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% TIMING \r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Acknowledgements  \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% INITIALISE\r\nglobal bncWordlist\r\nx =                 {'Vomftt qvstvfe, pqfo op eppst.', 'Ffmt dbo ljmm, opu pomz xpvoe.'};\r\nqSmall = 50;\r\nqBig = 1000;\r\n%cutoffTimeBig = 10;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\n\r\n% EDIT (2018-06-17).  Reduced time [slightly] to pose reasonable challenge.\r\n% Accounted for improving Cody server speed per Problem 44655.\r\ncutoffTimeBig = 8;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\ntRef = datetime('2018-06-17', 'InputFormat','yyyy-MM-dd');\r\ntNow = datetime('now');\r\nyearsElapsed = (datenum(tNow) - datenum(tRef)) / 365.24;\r\ndisp(' . ');\r\nfprintf('\\r\\n\\r\\n\\r\\nSubmission evaluated for speed on %s.\\r\\n', datestr(tNow, 'dd mmmm yyyy'))\r\nrInf = 0.2;   delta = cutoffTimeBig - rInf;  tau = 3.6;  % Data from Problem 44655, based on Problem 963.\r\nqBig = ceil( qBig * (cutoffTimeBig - rInf) * exp(yearsElapsed/tau) / delta );\r\nfprintf('\\r\\n\\r\\n\\r\\nTo account for computational power increases over time, number of iterations increased to %u.\\r\\n', qBig)\r\n% END EDIT (2018-06-17)\r\n\r\n\r\n% *** PRELIMINARY TIMING WITH timeit ***\r\nfDecode = @()   decode(x, bncWordlist);\r\ndt_timeit = timeit( fDecode );\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\nfprintf('APPROXIMATE time to decode %u message batches ~ %2.2f seconds, according to ''timeit''.\\n\\r', qBig, dt_timeit * qBig)\r\n\r\n% *** PRELIMINARY TIMING WITH SHORT LOOP ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode(x, bncWordlist);\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\n%fprintf('Your wall time to decode %u message batches = %i seconds.\\n\\r', qSmall, floor(dt))\r\nfprintf('APPROXIMATE wall time to decode %u message batches ~ %2.2f seconds, by extrapolating from %u batches.\\n\\r', qBig, dt * qBig / qSmall, qSmall)\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    % EDIT (2018-06-17).   Ensure each case is unique.\r\n    characters = ['  ,   .' char(randi([97,122], [1,23]))];\r\n    x{2} = characters( randperm(30) );\r\n    % END EDIT (2018-06-17)\r\n    solution = decode(x, bncWordlist);\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\nfprintf('Your wall time to decode %u message batches = %2.2f seconds.\\n\\r', qBig, dt)\r\n\r\ndt_cpu = (cputime - t0_cpu);\r\nfprintf(' ( Your CPU time for this = %2.2f seconds. ) \\n\\r', dt_cpu)\r\n\r\n% Display (default) Cody size-based score.\r\nall_nodes = mtree('decode.m', '-file');\r\nsize_score = count(all_nodes);\r\nfprintf('Your Cody-standard size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score\r\ncombinedScore = size_score + round(dt * 10);\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW.  It must be able to finish within %u seconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig, 'Exceeded time limit specified in Test Suite.' )","published":true,"deleted":false,"likes_count":2,"comments_count":16,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":"2019-07-02T13:23:18.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-10-12T23:17:24.000Z","updated_at":"2026-04-02T20:05:58.000Z","published_at":"2017-10-15T06:52:40.000Z","restored_at":"2017-10-25T07:03:11.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebetween\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (not within) batches — also, here you need to decode, not encode.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation. A few decoding options are at your organisation's disposal:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"Operation Phoenix\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethird option\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \\\"to be\\\", rather than the various inflected forms such as \\\"am\\\", \\\"is\\\", \\\"are\\\") like those based on the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.wordfrequency.info/free.asp?s=y\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCOCA\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, and after setting aside\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://world-english.org/english500.htm\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eanother list\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e you finally choose the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003elist based on the BNC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e as the most reliable, and will use the first 100 words on that list. This list will be available for you to access as an input variable,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebncWordlist\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, to your function. Note: (i) some entries on the list are morphemes (e.g. \\\" n't \\\" and \\\" 's \\\") rather than words; (ii) some entries appear more than once (representing different grammatical word classes). Of course, in the original messages any capitalisation might be used.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebncWordlist\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude; matching three-twentieths would be 50% certitude, and so on. Certitude shall be reported as a percentage, rounded\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eup\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to the nearest integer, not greater than 100. You need to maximise your certitude for each batch by appropriate choice of the shifting parameter. If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to crack the codes and report back in a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e] (usually scalar, but may be column vector); (2) the decoded messages [as a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ecell array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (containing\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e)] (usually an array with a single row, but occasionally with multiple rows); (3) your 'certitude' in the decoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e] (always scalar). The name of the structure array shall be\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, with respective fields\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eshift\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emessage\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecertitude\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEXAMPLE 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained two encoded messages —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Vomftt qvstvfe, pqfo op eppst.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Ffmt dbo ljmm, opu pomz xpvoe.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. Thus the original messages would have been: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Unless pursued, open no doors.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Eels can kill, not only wound.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . Twelve of the 51 characters have been matched: \\\"no\\\", \\\"can\\\", \\\"not\\\", and \\\"only\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would therefore comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(1)  \\ns.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\\ns.certitude = uint8(79)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEXAMPLE 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained one encoded message —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Oa oqvvq'u cnycau dggp: \\\"Ctu itcvkc ctvku\\\".\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied. In that case A→C, B→D, ..., Y→A, and Z→B; similarly, a→c, b→d, ..., y→a, and z→b. Thus the original message would have been: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"My motto's always been: \\\"Ars gratia artis\\\".\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . Eight of the 37 characters have been matched: \\\"My\\\", \\\" 's \\\", and \\\"been\\\". Note carefully that: \\\" 's \\\" should only be matched once; \\\"to\\\" (in motto), \\\"be\\\" (in been), \\\"at\\\" (in gratia), \\\"is\\\" (in artis) and \\\"a\\\" (passim) should\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e be matched at all; and \\\" ' \\\" will only ever be used as an apostrophe (never as a quotation mark).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would therefore comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(2)  \\ns.message = {'My motto''s always been: \\\"Ars gratia artis\\\".'}\\ns.certitude = uint8(73)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44356\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Orthos\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: TBA.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45212,"title":"AES MixColumns() Transformation","description":"Given a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm MixColumns() transformation and output a 16x2 character hexadecimal array.\r\n\r\nRefer to this link: \u003chttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003e\r\n\r\nFor example:\r\n\r\n  stateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\n  stateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];","description_html":"\u003cp\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm MixColumns() transformation and output a 16x2 character hexadecimal array.\u003c/p\u003e\u003cp\u003eRefer to this link: \u003ca href = \"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\"\u003ehttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003estateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];\r\n\u003c/pre\u003e","function_template":"function stateO = MixColumns(stateI)\r\n  stateO = stateI;\r\nend","test_suite":"%%\r\nstateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2']; \r\nstateO=['ea'\r\n    '75'\r\n    '96'\r\n    'de'\r\n    'e9'\r\n    'a0'\r\n    'fb'\r\n    '8a'\r\n    'f0'\r\n    '1c'\r\n    '09'\r\n    '9b'\r\n    '35'\r\n    '67'\r\n    '8d'\r\n    'bc'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['82';'c5';'61';'d4';'70';'4c';'37';'c5';'cb';'08';'4a';'1c';'82';'08';'a8';'3a']; \r\nstateO=['fe'\r\n    '64'\r\n    'e2'\r\n    '8a'\r\n    'c6'\r\n    '74'\r\n    '06'\r\n    '7a'\r\n    'c3'\r\n    '19'\r\n    '73'\r\n    '3c'\r\n    '95'\r\n    '4b'\r\n    '8f'\r\n    '49'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['13';'a6';'ef';'48';'51';'29';'9a';'a6';'1f';'30';'d6';'9c';'13';'30';'c2';'80']; \r\nstateO=['70'\r\n    '26'\r\n    'a8'\r\n    'ec'\r\n    'e5'\r\n    '10'\r\n    'a6'\r\n    '17'\r\n    '24'\r\n    '82'\r\n    '27'\r\n    'e4'\r\n    '34'\r\n    'ae'\r\n    '27'\r\n    'dc'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['70'\r\n    '26'\r\n    'a8'\r\n    'ec'\r\n    'e5'\r\n    '10'\r\n    'a6'\r\n    '17'\r\n    '24'\r\n    '82'\r\n    '27'\r\n    'e4'\r\n    '34'\r\n    'ae'\r\n    '27'\r\n    'dc'];\r\nstateO=['ce'\r\n    '33'\r\n    '32'\r\n    'dd'\r\n    '50'\r\n    '23'\r\n    '9b'\r\n    'ac'\r\n    '16'\r\n    'b6'\r\n    'df'\r\n    '1a'\r\n    '7a'\r\n    'c6'\r\n    'ab'\r\n    '76'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['ce'\r\n    '33'\r\n    '32'\r\n    'dd'\r\n    '50'\r\n    '23'\r\n    '9b'\r\n    'ac'\r\n    '16'\r\n    'b6'\r\n    'df'\r\n    '1a'\r\n    '7a'\r\n    'c6'\r\n    'ab'\r\n    '76'];\r\nstateO=['3d'\r\n    '23'\r\n    'e5'\r\n    'e9'\r\n    'f2'\r\n    '0c'\r\n    'b1'\r\n    '0b'\r\n    '28'\r\n    '01'\r\n    '2b'\r\n    '67'\r\n    '78'\r\n    '7d'\r\n    '6b'\r\n    '0f'];\r\nassert(isequal(MixColumns(stateI),stateO))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-21T18:10:13.000Z","updated_at":"2025-10-11T16:05:08.000Z","published_at":"2019-11-21T18:19:12.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm MixColumns() transformation and output a 16x2 character hexadecimal array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRefer to this link:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[stateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\\nstateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44924,"title":"Create State Array for initiating SHA-3-224 Hash","description":"Create binary represented state array (as the initial input to the sponge function (f)) from any length character array (N) with width (b=1600), digest length (d=224) and lane size (w=64) using SHA-3 Standard:\r\n\r\n\u003c\u003chttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf\u003e\u003e. \r\n\r\nConvert character array to binary representation using UTF-8 value of each character. Output state array will be a matrix with size (5,5,64). Padding in accordance with the standard is required. XOR of the rate bits (r) with the padded message stream is required.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 165px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 82.5px; transform-origin: 407px 82.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCreate binary represented state array (as the initial input to the sponge function (f)) from any length character array (N) with width (b=1600), digest length (d=224) and lane size (w=64) using SHA-3 Standard:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ehttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf    \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eConvert character array to binary representation using UTF-8 value of each character. Output state array will be a matrix with size (5,5,64). Padding in accordance with the standard is required. XOR of the rate bits (r) with the padded message stream is required (see figure 7, page 18). Just the first 1600 bit input to the first function (f) represented as a state array (see section 3.1.2) is required for the output.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function A = SHA3(N)\r\n  A=zeros(5,5,64);\r\nend","test_suite":"%%\r\nN = '';\r\nA='0110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\nassert(isequal(SHA3(N),reshape(reshape(A-48,[64,25])',[5,5,64])))\r\n%%\r\nN = 'abcdefghijklmnopqrstuvwxyz';\r\nA='1110000000000000000000000100000000000000000000000001000000000000000000000000010000000000000000000000011000000000000000000000000100000000000000000000001110000000000000000000000111000000000000000000000010000000000000000000000000110000000000000000000000000000000000000000000000001000000000000000000000001110000000000000000000000011000000000000000000000011100000000000000000000001000000000000000000000000011000000000000000000000001000000000000000000000000010000000000000000000000101000000000000000000000011100000000000000000000001110000000000000000000000100000000000000000000000001100000000000000000000000110000000000000000000000100000000000000000000000001100000000000000000000000110000000000000000000000111000000000000000000000010000000000000000000000000110000000000000000000000011000000000000000000000011100000000000000000000000010000000000000000000000111000000000000000000000011100000000000000000000001010000000000000000000000010000000000000000000000001000000000000000000000001100000000000000000000000111000000000000000000000001100000000000000000000001110000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000010100000000000000000000001110000000000000000000000111000000000000000000000011100000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000100000000000000000000000011000000000000000000000011100000000000000000000001100000000000000000000000000000000000000000000000010000000000000000000000000100000000000000000000000000000000000000000000000011000000000000000000000001100000000000000010000000';\r\nassert(isequal(SHA3(N),reshape(A-48,[5,5,64])))\r\n%%\r\nN = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nA='1100100110010011000000000000101010010010011000000011001110100011111100000000101010011011101000000000010111111111000011000000001110110011000101100000000010000111010110100000000110100001010011100000000010110101100011100000000000001001001000100100000000000011001001111001000000010011000011100001100000000011000001100100110000000111110000100001110000000011001001100101110100000001101001100100111100000000000011110101110010000000010001110001110111100000001111110101011011110000000111100100111000111000000011111000110111111000000001110110110001111010000000110111111000111011000000010101110010111011000000000111110110001010100000000000111100011000001000000001111000001000001100000000110010011000111100000000110100011010011101000000010011111001011100000000000010011010001100100000000100111001011101101000000011101001101110101100000000101001011101101010000000011000010100000110000000011011111101101110100000001001010100111110010000000000111110010010101000000000000101001110010000000001100100001110001010000000011100000110010011000000011100001111100101000000000100010010000111000000000101001111100011011000000000100110011111100100000000100110001011000010000000001110101011100010000000001101010111001101100000000111010011011001100000000110010111001001111000000010110111101100110100000001010011101001100000000000011011001011101010000000010111011000101111000000001111001110101101010000000111011111100110110000000011010011100110110000000001010011100001010000000000001001100000011100000000011001110000010110000000000011100010110001010000000001100001110000111000000000100111111000111100000001100100111000001000000000';\r\nassert(isequal(SHA3(N),reshape(A-48,[5,5,64])))\r\n%%\r\nN = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods. Third, adjust all your means to that end.';\r\nA='1100010111000111000000000011011110001111011000000000101010111111011000000000111110110101011010000000110110001011111001000000010110000011001101100000000111000111001110110000000110000111000101110000000010100011010001100100000000001111100001100000000000110011001011101010000000000101011001100101100000000111001101110100010000000101010100110101110000000011101001100100010100000001000010100001110100000000101000101110010110000000000000100100111110000000000001100101110010010000000101100000010000101000000001110001011101011000000001100000010110101010000000100000110001001001000000010100110000111000100000000000110100101100010000000001110110001110001000000011010011011010011100000001011111011000101100000000110001101000011100000000010100111010010110100000001011111011001100000000000000011000101101100000000010011000001100101100000000001010001101000110000000011001101100101111000000001001101101010110000000001000011000101110100000000000001110101110011000000011011100001111111100000001001101001111010000000000001100011110011111000000001100011110011111000000000100100110000111010000000100001111011111101000000000011110000111001100000000111110011111010000000000001110011111111100000000001110110011000100100000000111010111010001100000000110000111000111100000000010110011000001100000000000010101001000101000000000110011001011110000000000001011000011100100100000000011010111100001100000000011011110101011111000000011011011111001110000000001000001100100110110000000011000100011111010000000000010111010110100000000000011100101110000110000000011110110110010111000000011101001111010111000000001100000111010001010000000';\r\nassert(isequal(SHA3(N),reshape(A-48,[5,5,64])))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-06-18T00:59:47.000Z","updated_at":"2025-10-16T14:21:12.000Z","published_at":"2019-08-28T19:00:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate binary represented state array (as the initial input to the sponge function (f)) from any length character array (N) with width (b=1600), digest length (d=224) and lane size (w=64) using SHA-3 Standard:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ehttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf    \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConvert character array to binary representation using UTF-8 value of each character. Output state array will be a matrix with size (5,5,64). Padding in accordance with the standard is required. XOR of the rate bits (r) with the padded message stream is required (see figure 7, page 18). Just the first 1600 bit input to the first function (f) represented as a state array (see section 3.1.2) is required for the output.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44965,"title":"Optimal Asymmetric Encryption Padding decoding of message for RSA Cryptography","description":"EME-OAEP decoding by reversing the Feistel network using previously determined mask generation function (MGF1) and SHA-1 hashing. A matrix of octets is provided as the input (EM) which is the output of EME-OAEP encoding (see problem 44964/below link 7.1.2 page 21). The label (L) is not provided or checked against the encoded label. No error checks should be conducted. Output should be the character string represented by the octets.\r\n\r\nFor example:\r\n\r\n  EM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\r\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\r\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\r\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\r\n148,12,50,108,248,32,94];%input\r\n  M = 'I like to swim.';%output\r\n\r\n\u003chttps://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 275px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 137.5px; transform-origin: 407px 137.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eEME-OAEP decoding by reversing the Feistel network using previously determined mask generation function (MGF1) and SHA-1 hashing. A matrix of octets is provided as the input (EM) which is the output of EME-OAEP encoding (see problem 44964/below link, section 9.1.1.2). The label (L) is not provided or checked against the encoded label. No error checks should be conducted. Output should be the character string represented by the octets.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 120px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 60px; transform-origin: 404px 60px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e148,12,50,108,248,32,94];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eM = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'I like to swim.'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%output\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function  M  = EMEOAEPdecoding(EM)\r\n  M = 'I like to swim.';\r\nend","test_suite":"%%\r\nEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,148,12,50,108,248,32,94];\r\nM = 'I like to swim.';\r\nassert(isequal(EMEOAEPdecoding(EM),M))\r\n%%\r\nEM = [0   145   194    62    62   111    86   188    50    37   165   231    16    42    25    79   223   177   117   187   135   200   203   136   184   133    38   175    66    35   142   212   144   116    66    37   151     8   190   218    29   238   213    11   189   225    88    83   218   175   183    98    58   237    89    80   123    64    40   154   137    44    13   186    97   133    92    11   228    32   100   188    61    37   150   198   178    73   252    17   133   233    68    13    39    99     3   239   108   106   202   227   127   142    79    34   126   244    41    92   240     8   127   153   251    25    82    79   247    92   187    51    84    38   104   240    52   209   144   160   144   119   131    67   128   116    98   132    51    79     8   114    69   202    80   243   194    61    17    33   225   232   173     5   153   230    32   155    34    62    72     2   211   212   227     5   115   217    33   189    21   170    51   190   217   119   148    73   209   109   114    90   104   237   168    60   144   120   191     7   186     8   205   111   192   249   192   197    34   225   209   153   234     5    27   165    82    42   132   167   158    64   218   239    71    49   166    27    37     9   154     2   255   193    72    75     7   121   121   240    74   116   185    58    79   106    68    14    17    49    68    96   160     2    75    15   122   144    36    47   230   112    39   221    21   141   251   178    10   215   180   230   184   189   112   108   187    83    94   157    69   140   201    40   158   119    28   159   116   196   206   112    91   141    68   122   113   183    92   111    44   149   187   223   179   157    29    79   180   231    38   122   231    82    98    42    69    14   162    53];\r\nM = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nassert(isequal(EMEOAEPdecoding(EM),M))\r\n%%\r\nEM = [0    85    82   177   212   151     6   148    36   245   178   209   163    30    35   103   231   155   104   206    51   230   201    47   178   114   199    15   172   217   175    58    48   240   133     0   186   218    10   200    31   238   213    10   237   132    55    35   182   202   151    21    82   130   121    35    14    35    75   255   236    72    45   210     0   243    57    43   137    79     9   217    83    81   227   171   156   105   168   121   224   201    41    98    85     6    35   155     4    15   179   195    12   251    44    65    27   145    77   112   208   124    23   252   219   116    61    61   146   124   207    91    49    95    72   135    85   191   228   128   228    24   163    48   245    23     1   225    86    43    40    19    43   174   112   135   170    88    49    76   142   154   200    37   237   142    69   226     2    88    33   108   183   244   130    37     4   184    88   157    97   197    19   205   172    20   247    44   180     9    92   122    59   132   197    85   252    25   205   107   195    36   237    24   168   156   174   229    81   142   188   252   133   107   126   133    59    89   164   193   255    41   182   134    41    86   138    59    81    97   255    34   139   164    38    47    98    23    26   137   106    29   202    26    59     5   100   105   116    69   100    15   206    34    42    47    30   255    83    65   145    17    85   185    53   254   139   219   120   182   216   198   204   213    17    24   155    48    63   243   101   233   191    77   240    87   126   250    23   171   163    21   123   236   100     9    20   219    58    66    74   224   215   185   218   241   113    38   218   128     6    10   149    61    18    66    32   109   219    27   107   176    90   163   116    99    71    16   108    89   192   253   121   121    76   157   101   157   217    51    53   248   195    95    93   183    71    29   199     2   182    31   120    35   167    44   189   160     2   154   234   162   113   204    18   138    81   155    86   122   147    44    23   181    90   135    49   235    41   194    82   181    31    45   131    78   127   198   121   132    49     6   186    66   157   159    79   110   184   152    83   107    73    61    22    86   160   156   200   177    64   217    32   251   102     4   165   143   254   215   165   224   110    76    57    69    13   198   180   106   236    11    39   238     0   220    63   109   239   190    19    85    92    23    28   183   233    72    88   193     8   101   127   214   171     7    94   156   148   220    40    84    44   149     7   245   165   150   197    27    93   255   146    15   132   133   174   208     4   156   246    12    37    50    78    85    95   212   198    41    22   138   214   135   145   197   137   114   172   128    48   126   202   198     0    35    15    37   127     1    34    44   164    46   131    12    87   254     9   210   140    50    85   180   173   121    24    14   192   237    75   224    91   242   205   155     8   136    51    38   161     6   129   234    36     1    56   251    11     6    73    36    74   230    95   174    47    94    53   106   142    71   123    88    32    41     7   108    41   101    40   120   254   196    47   251    83   224   181   114   255   127    56     6   182   182   153   244   162   214   115   183   162    69    47   174   112    68    89   110   180    43    47   159   195   123    73   230   230   186   204   129   110   234   218   152    57   154   232    91    68   237   204   222   179   175   192   249     1   128     5   180    93    29    14    97   175   138   175   221   223   219    62    93   142    51   123   194    90     6   215    32   181    60    48    92   100   114    28   164    71   110   244   129   190   125    27   156   223   133     7   128    55   127    93     3    21    66    38   184    50    52     6   164   175    17   255   103    42    28   126    66    19   149    66     6   234   170   194   104    85    42   166   171   117   101    33    74    35   181    46   242   102   192   226   183   132   223   154    97   142   119   107     6    98    93   129   255   247   144   159    12   245   161   179    28     1   228    24    38   147    55   148    10   247   224   154   201   241    32    53    23   219    52     0   124    35    47    36    89   180    68    57   183   240    94   235    86   152   105    26   113    72    38    83   194   138    16    45   187    50   207   192   151    54    80   108   139   211   116   186   176    20   250    32   117   237   241   239   224   147   110    22   190    71    59    47    97     8   144   236   102     8   216   238   225    40   212   181   238   106   223    38   121   175    55    54   194   114   234   213    89    36   150   177   249    96   235    51    12   205    84   247   160    76];\r\nM = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nassert(isequal(EMEOAEPdecoding(EM),M))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-09-07T01:49:31.000Z","updated_at":"2025-10-15T13:23:25.000Z","published_at":"2019-09-07T01:56:46.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEME-OAEP decoding by reversing the Feistel network using previously determined mask generation function (MGF1) and SHA-1 hashing. A matrix of octets is provided as the input (EM) which is the output of EME-OAEP encoding (see problem 44964/below link, section 9.1.1.2). The label (L) is not provided or checked against the encoded label. No error checks should be conducted. Output should be the character string represented by the octets.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[EM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\\n148,12,50,108,248,32,94];%input\\nM = 'I like to swim.';%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":55070,"title":"Caesar Cipher Shift","description":"Given a word and its encrypted version using the caesar cipher, find the shift used.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGiven a word and its encrypted version using the caesar cipher, find the shift used.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function n = shift(d, e)\r\n  n = 0;\r\nend","test_suite":"%%\r\nd = 'Hello'\r\ne = 'Mjqqt'\r\nn_correct = 5;\r\nassert(isequal(shift(d, e), n_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":2446480,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-13T07:49:24.000Z","updated_at":"2026-02-10T08:53:18.000Z","published_at":"2022-07-13T07:49:24.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a word and its encrypted version using the caesar cipher, find the shift used.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1151,"title":"Decrypt Polybius ","description":"Decrypt Polybius square. Please refer to  Problem 1150 Polybius Square.\r\ninput [13 33 14 51] output 'cody';\r\ninput [23 0 26 33 44 15 0 31 11 42 26 11 12] returns 'i love matlab'.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 81px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 40.5px; transform-origin: 407px 40.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 129.5px 8px; transform-origin: 129.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eDecrypt Polybius square. Please refer to \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 1150 Polybius Square.\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 103.5px 8px; transform-origin: 103.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput [13 33 14 51] output 'cody';\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 211.5px 8px; transform-origin: 211.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput [23 0 26 33 44 15 0 31 11 42 26 11 12] returns 'i love matlab'.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = decrypt_polybius(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [13 33 14 51];\r\ny_correct = 'cody';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [23 0 26 33 44 15 0 31 11 42 26 11 12] ;\r\ny_correct = 'i love matlab';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [34 33 26 51 12 23 43 41];\r\ny_correct = 'polybius';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [31 11 42 22 45 33 36 25 41 0 31 11 14 15 0 31 11 42 26 11 12];\r\ny_correct = 'mathworks made matlab';\r\nassert(isequal(decrypt_polybius(x),y_correct))\r\n\r\n%%\r\nx = [51 33 0 41 43 34];\r\ny_correct = 'yo sup';\r\nassert(isequal(decrypt_polybius(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":35,"test_suite_updated_at":"2021-07-18T13:37:06.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-30T14:26:09.000Z","updated_at":"2025-08-14T15:41:08.000Z","published_at":"2012-12-30T14:26:09.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDecrypt Polybius square. Please refer to \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 1150 Polybius Square.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput [13 33 14 51] output 'cody';\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput [23 0 26 33 44 15 0 31 11 42 26 11 12] returns 'i love matlab'.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":45282,"title":"Cryptography with A Square Matrix : Decoding","description":"Previous Problem: Cryptography with A Square Matrix : Encoding\r\nNow decode a double vector to a (hopefully!) meaningful text.\r\nInputs are encoded vector and key matrix.\r\n   encodedVector = [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\r\n\r\n   key = magic(3);\r\ninverse of key\r\n   inverseKey = [0.147222222222222 -0.144444444444444 0.0638888888888889\r\n               -0.0611111111111111 0.0222222222222222 0.105555555555556\r\n               -0.0194444444444445 0.188888888888889 -0.102777777777778];\r\nReshape encodedVector so it has the same number of rows with key\r\n   reshapedVector = [1665 1549 486 1503 1192;\r\n                     1624 1495 510 1552 747;\r\n                     1541 1501 534 1595 836];\r\nMultiply inverseKey and reshapedVector, round it and reshape it;\r\n messageVector = [109 97 116 108 97 98 32 38 32 99 111 100 121 32 32];\r\nchar equivalent of message vector is 'matlab \u0026 cody'","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 449.333px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 224.667px; transform-origin: 407px 224.667px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 57.5px 8px; transform-origin: 57.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePrevious Problem:\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/45279-cryptography-with-a-square-matrix-encoding\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eCryptography with A Square Matrix : Encoding\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 193px 8px; transform-origin: 193px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNow decode a double vector to a (hopefully!) meaningful text.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 31.5px 8px; transform-origin: 31.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInputs are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 56px 8px; transform-origin: 56px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eencoded vector\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12px 8px; transform-origin: 12px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ekey\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22.5px 8px; transform-origin: 22.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 360px 8.5px; tab-size: 4; transform-origin: 360px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   encodedVector = [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   key = magic(3);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 31px 8px; transform-origin: 31px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einverse of\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12px 8px; transform-origin: 12px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ekey\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 288px 8.5px; tab-size: 4; transform-origin: 288px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   inverseKey = [0.147222222222222 -0.144444444444444 0.0638888888888889\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 284px 8.5px; tab-size: 4; transform-origin: 284px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e               -0.0611111111111111 0.0222222222222222 0.105555555555556\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 292px 8.5px; tab-size: 4; transform-origin: 292px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e               -0.0194444444444445 0.188888888888889 -0.102777777777778];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReshape\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 53.5px 8px; transform-origin: 53.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eencodedVector\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 124px 8px; transform-origin: 124px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e so it has the same number of rows with\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12px 8px; transform-origin: 12px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ekey\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 180px 8.5px; tab-size: 4; transform-origin: 180px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   reshapedVector = [1665 1549 486 1503 1192;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 176px 8.5px; tab-size: 4; transform-origin: 176px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                     1624 1495 510 1552 747;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 180px 8.5px; tab-size: 4; transform-origin: 180px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                     1541 1501 534 1595 836];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 23.5px 8px; transform-origin: 23.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eMultiply\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 40px 8px; transform-origin: 40px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003einverseKey\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14px 8px; transform-origin: 14px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 56px 8px; transform-origin: 56px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ereshapedVector\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 77.5px 8px; transform-origin: 77.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, round it and reshape it;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 280px 8.5px; tab-size: 4; transform-origin: 280px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e messageVector = [109 97 116 108 97 98 32 38 32 99 111 100 121 32 32];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 165px 8px; transform-origin: 165px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003echar equivalent of message vector is 'matlab \u0026amp; cody'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function hopefullyMeaningfulText = decodeMessage(encodedVector, keyMatrix)\r\n\r\nend","test_suite":"%%\r\nencodedVector = [1665 1624 1541 1549 1495 1501 1013 1351 1221 1426 1153 886 1714 1680 1586 480 480 480];\r\nkeyMatrix = magic(3);\r\ny_correct = 'matlab and cody';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [6829 6941 7028 6905 6877 6043 5432 6941 6575 6469 3236 3644 2352 2760 2828];\r\nkeyMatrix = magic(5);\r\ny_correct = 'hello world';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [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];\r\nkeyMatrix = [14 20 63; 54 46 5; 71 27 24];\r\ny_correct = 'stockout is an order that cannot be satisfied, resulting in a loss of the sale.';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [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];\r\nkeyMatrix = [7 92 23; 34 77 7; 89 66 32 ];\r\ny_correct = 'dasiy is a small white flower with a yellow centre.';\r\nassert(isequal(decodeMessage(encodedVector, keyMatrix),y_correct))\r\n\r\n%%\r\nencodedVector = [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];\r\nkeyMatrix = [7 92 23; 34 77 7; 89 66 32 ];\r\ndecodeMessage(encodedVector, keyMatrix)\r\n\r\n%%\r\nencodedVector = [23314 25294 21847 18481 14593 16573 17959 19939 21334];\r\nkeyMatrix = magic(9);\r\ndecodeMessage(encodedVector, keyMatrix)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":8703,"edited_by":223089,"edited_at":"2022-12-28T13:35:31.000Z","deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2022-12-28T13:35:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-01-28T08:55:42.000Z","updated_at":"2025-06-15T06:19:47.000Z","published_at":"2020-01-28T08:56:34.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious Problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45279-cryptography-with-a-square-matrix-encoding\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCryptography with A Square Matrix : Encoding\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNow decode a double vector to a (hopefully!) meaningful text.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInputs are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eencoded vector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   encodedVector = [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\\n\\n   key = magic(3);]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einverse of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   inverseKey = [0.147222222222222 -0.144444444444444 0.0638888888888889\\n               -0.0611111111111111 0.0222222222222222 0.105555555555556\\n               -0.0194444444444445 0.188888888888889 -0.102777777777778];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReshape\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eencodedVector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e so it has the same number of rows with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   reshapedVector = [1665 1549 486 1503 1192;\\n                     1624 1495 510 1552 747;\\n                     1541 1501 534 1595 836];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMultiply\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einverseKey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereshapedVector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, round it and reshape it;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ messageVector = [109 97 116 108 97 98 32 38 32 99 111 100 121 32 32];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003echar equivalent of message vector is 'matlab \u0026amp; cody'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1150,"title":"Polybius Square","description":"Given a string, calculate the coordinates. Input will be always in lowercase. If string is a sentence then use 0 (zero) to indicate the space between words.\r\n   1 2 3 4 5 6\r\n1  a b c d e f \r\n2  g h i j k l\r\n3  m n o p q r\r\n4  s t u v w x\r\n5  y z\r\ninput 'cody' returns [13 33 14 51] and\r\ninput 'i love matlab' returns [23 0 26 33 44 15 0 31 11 42 26 11 12].\r\nFor more information refer to. Please note that another colum (6th column) is added in order to seperate letter i and letter j. That means table in this question is different from reference page.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 286.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 143.3px; transform-origin: 407px 143.3px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a string, calculate the coordinates. Input will be always in lowercase. If string is a sentence then use 0 (zero) to indicate the space between words.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 61.3px; transform-origin: 404px 61.3px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e   1 2 3 4 5 6\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e1  a \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 40px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 40px 8.5px; \"\u003eb c d e f \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e2  g \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003eh i j k l\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e3  m \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003en o p q r\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e4  s \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003et u v w x\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 24px 8.5px; transform-origin: 24px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 20px 8.5px; transform-origin: 20px 8.5px; \"\u003e5  y \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 4px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 4px 8.5px; \"\u003ez\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 118px 8px; transform-origin: 118px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput 'cody' returns [13 33 14 51] and\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 211.5px 8px; transform-origin: 211.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003einput 'i love matlab' returns [23 0 26 33 44 15 0 31 11 42 26 11 12].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 66px 8px; transform-origin: 66px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor more information\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003erefer to\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 293px 8px; transform-origin: 293px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Please note that another colum (6th column) is added in order to seperate letter i and letter j. That means table in this question is different from reference page.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = polybius(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'do not cheat';\r\ny_correct = [14 33 0 32 33 42 0 13 22 15 11 42];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'cody';\r\ny_correct = [13 33 14 51];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'polybius';\r\ny_correct = [34 33 26 51 12 23 43 41];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'i love matlab';\r\ny_correct = [23 0 26 33 44 15 0 31 11 42 26 11 12];\r\nassert(isequal(polybius(x),y_correct))\r\n\r\n%%\r\nx = 'covid is a deadly virus';\r\ny_correct = [13 33 44 23 14 0 23 41 0 11 0 14 15 11 14 26 51 0 44 23 36 43 41];\r\nassert(isequal(polybius(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":"2021-07-18T13:42:32.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-30T13:33:11.000Z","updated_at":"2026-03-16T11:33:34.000Z","published_at":"2012-12-30T14:03:05.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a string, calculate the coordinates. Input will be always in lowercase. If string is a sentence then use 0 (zero) to indicate the space between words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   1 2 3 4 5 6\\n1  a b c d e f \\n2  g h i j k l\\n3  m n o p q r\\n4  s t u v w x\\n5  y z]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput 'cody' returns [13 33 14 51] and\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003einput 'i love matlab' returns [23 0 26 33 44 15 0 31 11 42 26 11 12].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor more information\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erefer to\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Please note that another colum (6th column) is added in order to seperate letter i and letter j. That means table in this question is different from reference page.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":54835,"title":"Caesar Cipher","description":"Given a input word x and a shift n, encrypt the word with caesar cipher of shift n.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGiven a input word x and a shift n, encrypt the word with caesar cipher of shift n.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = caesar_cipher(x, n)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'Hello';\r\nn = 5;\r\ny_correct = 'Mjqqt';\r\nassert(isequal(caesar_cipher(x, n), y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":2446480,"edited_by":2446480,"edited_at":"2022-07-12T12:55:35.000Z","deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-12T12:55:13.000Z","updated_at":"2022-07-12T12:55:35.000Z","published_at":"2022-07-12T12:55:35.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a input word x and a shift n, encrypt the word with caesar cipher of shift n.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":751,"title":"Implement simple rotation cypher","description":"If given a letter from the set:\r\n\r\n  [abc...xyz]\r\n\r\nand a shift, implement a shift cypher.\r\n\r\nExample:\r\n\r\n  'abc' \r\n\r\nwith a shift of -1 yields\r\n\r\n  'zab'\r\n\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eIf given a letter from the set:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e[abc...xyz]\r\n\u003c/pre\u003e\u003cp\u003eand a shift, implement a shift cypher.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e'abc' \r\n\u003c/pre\u003e\u003cp\u003ewith a shift of -1 yields\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e'zab'\r\n\u003c/pre\u003e","function_template":"function outStr = cypher(inStr, shift)\r\n  outStr = inStr;\r\nend","test_suite":"%%\r\ninStr = 'doug';\r\nshift = 10;\r\noutStr = 'nyeq';\r\n\r\nassert(isequal(cypher(inStr, shift),outStr))\r\n\r\n%%\r\ninStr = 'thequickbrownfox';\r\nshift = 5;\r\noutStr = 'ymjvznhpgwtbsktc';\r\n\r\nassert(isequal(cypher(inStr, shift),outStr))\r\n\r\n%%\r\ninStr = 'thecrowfliesatmidnight';\r\nshift = 22;\r\noutStr = 'pdaynksbheaowpiezjecdp';\r\n\r\nassert(isequal(cypher(inStr, shift),outStr))","published":true,"deleted":false,"likes_count":13,"comments_count":2,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1096,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":6,"created_at":"2012-06-06T15:38:43.000Z","updated_at":"2026-02-19T13:12:57.000Z","published_at":"2012-06-08T19:08:23.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf given a letter from the set:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[[abc...xyz]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eand a shift, implement a shift cypher.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA['abc']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewith a shift of -1 yields\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA['zab']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":61050,"title":"Generate Secret Key for Cryptography ","description":"From a seed file (code.wav), decode the audio file (Bell 202 format at 200 bits/sec) into a binary stream and then convert the binary stream into a decimal vector (uint8) that should be hashed using SHA - 224, 256, 384, or 514 based on the function input. Output the hexadecimal hash (in lower case). ","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.440001px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 63px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 344px 31.5px; transform-origin: 344px 31.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 321px 31.5px; text-align: left; transform-origin: 321px 31.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFrom a seed file (code.wav), decode the audio file (Bell 202 format at 200 bits/sec) into a binary stream and then convert the binary stream into a decimal vector (uint8) that should be hashed using SHA - 224, 256, 384, or 514 based on the function input. Output the hexadecimal hash (in lower case). \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function s = generateSecretKey(d)\r\ns='ab13';\r\nend","test_suite":"%%\r\ndropboxLink = 'https://www.dropbox.com/scl/fi/9g51et5mg6oir3rzckgmq/code.wav?rlkey=kujbm4wvj8k8n2fsav36ie3fo\u0026st=udr92tru\u0026dl=1';\r\nwebsave('code.wav', dropboxLink);\r\nassert(isequal('9b9011a6f9075acc3bf9aa9d58f117d2a457df1ad4c1fc800654ed4728699654',generateSecretKey(256)));\r\nassert(isequal('b4d6dfe609125ee60a481568d23ecdd0394ee272b50ef9e901c8d3610fbf64dad79ef569607864da83b635b590edf2a82a7d300fb37f9a61664d05b1445dc3a9',generateSecretKey(512)));\r\nassert(isequal('125da2fb2c851a0ec8d1feb68e5f6b7c5e951b809e3b58400c955840',generateSecretKey(224)));\r\nassert(isequal('fa4391ce471e89fc5232aa0aa9d8ed70738fc526029370f09fd9cb4d7439e8825aeacba72ea65a6109b7a964ae4cf114',generateSecretKey(384)));\r\n%%\r\ndropboxLink = 'https://www.dropbox.com/scl/fi/ezhpy2a6u9tel2v53pdco/code1.wav?rlkey=5yg3bx0dqochp2jcalvzjs1ws\u0026st=d5ekkeuw\u0026dl=1';\r\nwebsave('code.wav', dropboxLink);\r\nassert(isequal('1fd510e7e4777fd25aa2b75468ea9949fac17fa43004c92c8f906da57a0856a2',generateSecretKey(256)));\r\nassert(isequal('48132c1a6789a3a4c161436fd9b09353767a8dad70c90f7c37bd8fe89a15cad3d961ac2c0fe594fe951ede62dca77cff4a67668bd0d35091b60ad46e547dd883',generateSecretKey(512)));\r\nassert(isequal('de27d369a5ecf458537c39fac1d7a3d5d075dfbbd251caa110a1340d',generateSecretKey(224)));\r\nassert(isequal('0e3d5fb4ec12cd4cc97d1c272afa8c3d280d1626727f4366ce41acd0ece2aeeee6357bd29aa6833b18f75a9744766fb6',generateSecretKey(384)));\r\n%%\r\ndropboxLink = 'https://www.dropbox.com/scl/fi/a2tmz2axfex2sxa1pm4f6/code2.wav?rlkey=4p50pxytoyudkgv27hnskhamr\u0026st=eocw0ote\u0026dl=1';\r\nwebsave('code.wav', dropboxLink);\r\nassert(isequal('689dd116f955d1489ae5a0b82731e8f641de70366cf153c273a5aceb0bce882d',generateSecretKey(256)));\r\nassert(isequal('0bdbb0437718cf66746eaeb083217127a165f3cb4fed63132859cf1dcc79b78ac7997d00d6460e2b9853980de69ee7819a1605488ece34c84efbfa790cad516e',generateSecretKey(512)));\r\nassert(isequal('1fc1b7790c3bc1e2f7d292befca59d5f553e272898691e37d5d68b98',generateSecretKey(224)));\r\nassert(isequal('61e71c53762b02af99b8b4b212dc4cd78ba71750ab97927d52d2d63f36fbdb26e1e203b32b87867b1e8c0ac44de2531a',generateSecretKey(384)));\r\n%%\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":145982,"edited_by":145982,"edited_at":"2025-10-27T11:40:10.000Z","deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2025-10-25T00:11:13.000Z","updated_at":"2026-02-26T14:02:17.000Z","published_at":"2025-10-25T00:11:13.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFrom a seed file (code.wav), decode the audio file (Bell 202 format at 200 bits/sec) into a binary stream and then convert the binary stream into a decimal vector (uint8) that should be hashed using SHA - 224, 256, 384, or 514 based on the function input. Output the hexadecimal hash (in lower case). \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1953,"title":"Simple Caesar Cypher - shift encrypt a message given an index number","description":"A Caesar cypher is a simple shift encryption method. Your goal is to create a function that allows a user to input a string and a shift index and outputs the shifted cypher-text as a string.\r\n\r\nThe shift index is an integer that tells the encryption method how many letters to shift each letter in the message forward. For example, a shift index of 3 will shift the letter \"a\" to be \"d\", \"b\" to be \"e\" and so on. In this problem we will just use the 26 lowercase letters in the english alphabet, and any capital letters in the message should be converted to lowercase. The ordering of letters will wrap around after \"z\", so that a \"y\" shifted by 3 will become a \"b\".\r\n\r\nAny integer number (positive, negative, and of any magnitude) should be acceptable as the shift index.\r\n\r\nExamples:\r\n\r\ncaesarShift('zebra',7) --\u003e 'gliyh'\r\n\r\ncaesarShift('LiOn',-5) --\u003e 'gdji'","description_html":"\u003cp\u003eA Caesar cypher is a simple shift encryption method. Your goal is to create a function that allows a user to input a string and a shift index and outputs the shifted cypher-text as a string.\u003c/p\u003e\u003cp\u003eThe shift index is an integer that tells the encryption method how many letters to shift each letter in the message forward. For example, a shift index of 3 will shift the letter \"a\" to be \"d\", \"b\" to be \"e\" and so on. In this problem we will just use the 26 lowercase letters in the english alphabet, and any capital letters in the message should be converted to lowercase. The ordering of letters will wrap around after \"z\", so that a \"y\" shifted by 3 will become a \"b\".\u003c/p\u003e\u003cp\u003eAny integer number (positive, negative, and of any magnitude) should be acceptable as the shift index.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003ecaesarShift('zebra',7) --\u003e 'gliyh'\u003c/p\u003e\u003cp\u003ecaesarShift('LiOn',-5) --\u003e 'gdji'\u003c/p\u003e","function_template":"function cyphertext = caesarShift(message, shift)\r\ncyphertext=message;\r\nend","test_suite":"%%\r\nmessage = 'elephant';\r\nshift = 45;\r\ncorrect = 'xexiatgm';\r\nassert(isequal(caesarShift(message,shift),correct))\r\n\r\n%%\r\nmessage = 'TiGEr';\r\nshift = -537;\r\nanswer = 'crpna';\r\nassert(isequal(caesarShift(message,shift),answer))\r\n\r\n%%\r\nmessage = 'gozoaobrsf'\r\nshift = 12;\r\nanswer = 'salamander';\r\nassert(isequal(caesarShift(message,shift),answer))\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":15293,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":110,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":28,"created_at":"2013-10-21T17:12:02.000Z","updated_at":"2026-03-06T20:51:45.000Z","published_at":"2013-10-21T17:12:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA Caesar cypher is a simple shift encryption method. Your goal is to create a function that allows a user to input a string and a shift index and outputs the shifted cypher-text as a string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe shift index is an integer that tells the encryption method how many letters to shift each letter in the message forward. For example, a shift index of 3 will shift the letter \\\"a\\\" to be \\\"d\\\", \\\"b\\\" to be \\\"e\\\" and so on. In this problem we will just use the 26 lowercase letters in the english alphabet, and any capital letters in the message should be converted to lowercase. The ordering of letters will wrap around after \\\"z\\\", so that a \\\"y\\\" shifted by 3 will become a \\\"b\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAny integer number (positive, negative, and of any magnitude) should be acceptable as the shift index.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ecaesarShift('zebra',7) --\u003e 'gliyh'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ecaesarShift('LiOn',-5) --\u003e 'gdji'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45279,"title":"Cryptography with A Square Matrix : Encoding","description":"Matrix inverse operation can be used to encode or decode of a message. For example \r\n\r\n    text = 'matlab \u0026 cody'. \r\n\r\nnumeric equivalent is \r\n\r\n    num = [109 97 116 108 97 98 32 38 32 99 111 100 121]\r\n\r\n\r\nlet \r\n\r\n   key = magic(3);\r\n\r\n\r\n*key* is an arbitrary square matrix and its inverse is exist. \r\n\r\nreshape the vector *num* so it has the same number of rows with *key* matrix\r\n\r\n   numMatrix = [109 108 32 99 121;\r\n                 97 97 38 111 32;\r\n                116 98 32 100 32];\r\n\r\nNote that last two elements are filled with 32 which is the numeric equivalent of blank character ' '.\r\n\r\nFinally multiply *key* with *numMatrix* (and reshape it) to obtain an encoded vector.\r\n\r\n   encodedVector= [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\r\n\r\nif you multiply *inverse of key* with reshaped *encodedVector* you can obtain the ascii numbers of secret message.\r\n\r\nNext Problem : \u003chttps://www.mathworks.com/matlabcentral/cody/problems/45282-cyrptography-with-a-square-matrix-decoding Cryptography with A Square Matrix : Decoding\u003e\r\n\r\nInspired from:\r\n\r\nBarnett, R.A., Ziegler, M.R. and Byleen, K.E. (2015). Finite Mathematics for Business, Economics, Life Sciences, and Social Sciences. Pearson, 13th (Global) Edition. p:245-247.","description_html":"\u003cp\u003eMatrix inverse operation can be used to encode or decode of a message. For example\u003c/p\u003e\u003cpre\u003e    text = 'matlab \u0026 cody'. \u003c/pre\u003e\u003cp\u003enumeric equivalent is\u003c/p\u003e\u003cpre\u003e    num = [109 97 116 108 97 98 32 38 32 99 111 100 121]\u003c/pre\u003e\u003cp\u003elet\u003c/p\u003e\u003cpre\u003e   key = magic(3);\u003c/pre\u003e\u003cp\u003e\u003cb\u003ekey\u003c/b\u003e is an arbitrary square matrix and its inverse is exist.\u003c/p\u003e\u003cp\u003ereshape the vector \u003cb\u003enum\u003c/b\u003e so it has the same number of rows with \u003cb\u003ekey\u003c/b\u003e matrix\u003c/p\u003e\u003cpre\u003e   numMatrix = [109 108 32 99 121;\r\n                 97 97 38 111 32;\r\n                116 98 32 100 32];\u003c/pre\u003e\u003cp\u003eNote that last two elements are filled with 32 which is the numeric equivalent of blank character ' '.\u003c/p\u003e\u003cp\u003eFinally multiply \u003cb\u003ekey\u003c/b\u003e with \u003cb\u003enumMatrix\u003c/b\u003e (and reshape it) to obtain an encoded vector.\u003c/p\u003e\u003cpre\u003e   encodedVector= [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]\u003c/pre\u003e\u003cp\u003eif you multiply \u003cb\u003einverse of key\u003c/b\u003e with reshaped \u003cb\u003eencodedVector\u003c/b\u003e you can obtain the ascii numbers of secret message.\u003c/p\u003e\u003cp\u003eNext Problem : \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/45282-cyrptography-with-a-square-matrix-decoding\"\u003eCryptography with A Square Matrix : Decoding\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInspired from:\u003c/p\u003e\u003cp\u003eBarnett, R.A., Ziegler, M.R. and Byleen, K.E. (2015). Finite Mathematics for Business, Economics, Life Sciences, and Social Sciences. Pearson, 13th (Global) Edition. p:245-247.\u003c/p\u003e","function_template":"function encodedVector = encodeMessage(inputString,keyMatrix)\r\n\r\nend","test_suite":"%%\r\ninputString = 'matlab and cody';\r\nkeyMatrix = magic(3);\r\ny_correct = [1665 1624 1541 1549 1495 1501 1013 1351 1221 1426 1153 886 1714 1680 1586 480 480 480];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n%%\r\ninputString = 'matlab and cody'\r\nkeyMatrix = magic(5);\r\ny_correct = [6616 6868 6820 7017 6934 4911 6233 6245 5817 5199 5646 5344 6827 6080 6198 2080 2080 2080 2080 2080];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n%%\r\ninputString = 'Hello worlD!!';\r\nkeyMatrix = magic(3);\r\ny_correct = [1325 1477 1413 1167 1103 1495 1747 1710 1703 1130 895 1110 488 483 484];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n%%\r\ninputString = 'Hello worlD!!'\r\nkeyMatrix = magic(5);\r\ny_correct = [6285 6205 6900 6585 6525 6043 5432 6941 6575 6469 2717 2920 2243 2471 2519];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n\r\n%%\r\ninputString = 'What a wonderful day!'\r\nkeyMatrix = [41 6; 46 46];\r\ny_correct = [4191 8786 4673 9798 1894 5934 2026 6946 5211 10166 4706 9246 5286 9936 5445 10350 1912 6072 4703 10028 1545 2990];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n\r\n%%\r\ninputString = '3'\r\nkeyMatrix = [41 6; 46 46];\r\ny_correct = [2283 3818];\r\nassert(isequal(encodeMessage(inputString, keyMatrix),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":"2020-01-28T16:27:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-01-27T13:50:56.000Z","updated_at":"2020-01-28T16:27:49.000Z","published_at":"2020-01-28T08:56:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMatrix inverse operation can be used to encode or decode of a message. For example\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    text = 'matlab \u0026 cody'.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003enumeric equivalent is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    num = [109 97 116 108 97 98 32 38 32 99 111 100 121]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003elet\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   key = magic(3);]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is an arbitrary square matrix and its inverse is exist.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ereshape the vector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enum\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e so it has the same number of rows with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e matrix\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   numMatrix = [109 108 32 99 121;\\n                 97 97 38 111 32;\\n                116 98 32 100 32];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that last two elements are filled with 32 which is the numeric equivalent of blank character ' '.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFinally multiply\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ekey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enumMatrix\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (and reshape it) to obtain an encoded vector.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   encodedVector= [1665 1624 1541 1549 1495 1501 486 510 534 1503 1552 1595 1192 747 836]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif you multiply\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einverse of key\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e with reshaped\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eencodedVector\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e you can obtain the ascii numbers of secret message.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNext Problem :\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45282-cyrptography-with-a-square-matrix-decoding\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCryptography with A Square Matrix : Decoding\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInspired from:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBarnett, R.A., Ziegler, M.R. and Byleen, K.E. (2015). Finite Mathematics for Business, Economics, Life Sciences, and Social Sciences. Pearson, 13th (Global) Edition. p:245-247.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44351,"title":"Code breaker, Part I:  Operation Phoenix","description":"You have been tasked with decoding a set of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).  \r\n\r\nYou can also assume that the original message will relate to an activity that is referred to by those involved as \"Operation Phoenix\". Therefore the phrase \"Operation Phoenix\" (with that capitalisation) would have appeared at least once in the original message.  \r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e];  (2)  the decoded message [as \u003chttp://au.mathworks.com/help/matlab/ref/char.html character array\u003e].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".  \r\n\r\nEXAMPLE\r\n\r\nSuppose the original message was _\"Cancel Operation Phoenix immediately \u0026 escape.\"_ and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the encoded message would be:  _\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.\"_\r\n\r\nThe correct answer would comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = 'Cancel Operation Phoenix immediately \u0026 escape.'\r\n\r\n|Note: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\r\n\r\n----------\r\n\r\nNext problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44356 Operation Orthos\u003e.\r\n\r\n----------\r\n\r\nStatistics on solutions submitted as at 15 October 2017:\r\n\r\n* *Fastest wall time to decode 5000 messages = 93 milliseconds* , for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303 Solution 1279303\u003e, with a size-based score of 40. \r\n* *Smallest size-based score = 38* , for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780 Solution 1278780\u003e, for which wall time to decode 5000 messages = 515 milliseconds.  \r\n* Best combined score = 49, for \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303 Solution 1279303\u003e. ","description_html":"\u003cp\u003eYou have been tasked with decoding a set of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).\u003c/p\u003e\u003cp\u003eYou can also assume that the original message will relate to an activity that is referred to by those involved as \"Operation Phoenix\". Therefore the phrase \"Operation Phoenix\" (with that capitalisation) would have appeared at least once in the original message.\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e];  (2)  the decoded message [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter array\u003c/a\u003e].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cp\u003eSuppose the original message was \u003ci\u003e\"Cancel Operation Phoenix immediately \u0026 escape.\"\u003c/i\u003e and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the encoded message would be:  \u003ci\u003e\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.\"\u003c/i\u003e\u003c/p\u003e\u003cp\u003eThe correct answer would comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = 'Cancel Operation Phoenix immediately \u0026 escape.'\r\n\u003c/pre\u003e\u003cp\u003e\u003ctt\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003eNext problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44356\"\u003eOperation Orthos\u003c/a\u003e.\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003eStatistics on solutions submitted as at 15 October 2017:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003cb\u003eFastest wall time to decode 5000 messages = 93 milliseconds\u003c/b\u003e , for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\"\u003eSolution 1279303\u003c/a\u003e, with a size-based score of 40.\u003c/li\u003e\u003cli\u003e\u003cb\u003eSmallest size-based score = 38\u003c/b\u003e , for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780\"\u003eSolution 1278780\u003c/a\u003e, for which wall time to decode 5000 messages = 515 milliseconds.\u003c/li\u003e\u003cli\u003eBest combined score = 49, for \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\"\u003eSolution 1279303\u003c/a\u003e.\u003c/li\u003e\u003c/ul\u003e","function_template":"function s = decode(x)\r\n  s = x;\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions, \r\n% so your score/size may therefore change over time.  \r\n\r\n\r\n%% Test 1\r\nx = 'Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.';\r\ns_correct.shift = 1;\r\ns_correct.message = 'Cancel Operation Phoenix immediately \u0026 escape.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 2\r\nx = 'Vwlyhapvu Wovlupe ilnpuz Ablzkhf!  Vwlyhapvu Wovlupe pz vby avw wypvypaf.';\r\ns_correct.shift = 7;\r\ns_correct.message = 'Operation Phoenix begins Tuesday!  Operation Phoenix is our top priority.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 3\r\nx = 'Eatpht cdit iwpi iwt ephhldgs wph qttc rwpcvts ugdb \"Fxeudyn\" id \"Dvcsbwl\".  Diwtglxht Detgpixdc Ewdtcxm xh egdrttsxcv prrdgsxcv id eapc.';\r\ns_correct.shift = 15;\r\ns_correct.message = 'Please note that the password has been changed from \"Qipfojy\" to \"Ogndmhw\".  Otherwise Operation Phoenix is proceeding according to plan.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Test 4\r\nx = 'Mncpyrgml Nfmclgv qryprcb rfpcc bywq yem.  Yjj ncpqmllcj ypc rm pckygl ml bsrw slrgj Mncpyrgml Nfmclgv gq amknjcrcb.';\r\ns_correct.shift = 24;\r\ns_correct.message = 'Operation Phoenix started three days ago.  All personnel are to remain on duty until Operation Phoenix is completed.';\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'char') )\r\n\r\n\r\n%% Rescoring \r\n% Acknowledgements \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Initialise\r\nx = 'Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026 ftdbqf.';\r\ncutoffTimeBig = 1000; % Maximum allowable walltime (in milliseconds) to run function in a loop with qBig iterations.\r\n\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\n\r\n% Run once, untimed?\r\nincludeOverheads = false;\r\nif includeOverheads, \r\n    solution = decode( x );\r\nend;\r\n\r\n% *** PRELIMINARY TIMING ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nqSmall = 50;\r\nqBig = 5000;\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0) * 1000;\r\ndisp('     -----=====-----     ')\r\nfprintf('Your wall time to decode %u messages = %i msec.\\n\\r', qSmall, floor(dt))\r\nfprintf('Your APPROXIMATE wall time to decode %u messages would be ~ %i msec.\\n\\r', qBig, ceil(dt * qBig / qSmall))\r\ndisp('     -----=====-----     ')\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\nfor dummy = 1 : 20,  disp(' . ');  end;\r\ndisp('     -----=====|||||=====-----     ')\r\ndt = etime(clock, t0) * 1000;\r\nfprintf('Your wall time to decode %u messages = %i msec.\\n\\r', qBig, floor(dt))\r\n\r\ndt_cpu = (cputime - t0_cpu) * 1000;\r\nfprintf(' ( Your CPU time for this = %i msec. ) \\n\\r', floor(dt_cpu))\r\n\r\nfDecode = @()   decode(x);\r\ndt_timeit = timeit( fDecode ) * 1000;\r\nfprintf(' [ Your ''timeit'' time to decode %u messages = %i msec. ] \\n\\r', qBig, ceil(dt_timeit * qBig))\r\n\r\n% Display a size-based score.\r\nall_nodes = mtree('decode.m', '-file');        % This is the default in Cody.\r\nstr_nodes = mtfind(all_nodes, 'Kind', 'STRING');\r\neq_nodes = mtfind(all_nodes, 'Kind', 'EQUALS');\r\nprint_nodes = mtfind(all_nodes, 'Kind', 'PRINT');\r\nexpr_nodes = mtfind(all_nodes, 'Kind', 'EXPR');\r\n\r\nsize_score = count(all_nodes) ...\r\n +sum(str_nodes.nodesize-1) ...\r\n +2*(count(expr_nodes) ...\r\n +count(print_nodes) ...\r\n -count(eq_nodes));\r\n\r\nfprintf('Your size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score.\r\ncombinedScore = size_score  +  min( 200, floor(dt*(500/qBig)) );\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW. It must be able to finish within %u milliseconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig, 'Exceeded time limit specified in Test Suite.' )","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":45,"test_suite_updated_at":"2017-10-15T10:19:08.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2017-09-29T09:20:59.000Z","updated_at":"2026-04-02T08:27:57.000Z","published_at":"2017-09-29T13:45:26.000Z","restored_at":"2017-10-04T19:25:07.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been tasked with decoding a set of coded messages that have been intercepted.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were encoded using a simple\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026amp; numbers) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between messages (also, here you need to decode, not encode).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou can also assume that the original message will relate to an activity that is referred to by those involved as \\\"Operation Phoenix\\\". Therefore the phrase \\\"Operation Phoenix\\\" (with that capitalisation) would have appeared at least once in the original message.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to crack the codes and report back in a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]; (2) the decoded message [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]. The name of the structure array shall be \\\"s\\\", with respective fields \\\"shift\\\" and \\\"message\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the original message was\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Cancel Operation Phoenix immediately \u0026amp; escape.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. (Note that the shifting 'wraps' back around.) Thus the encoded message would be: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Dbodfm Pqfsbujpo Qipfojy jnnfejbufmz \u0026amp; ftdbqf.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(1)  \\ns.message = 'Cancel Operation Phoenix immediately \u0026 escape.']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable and doesn't generate excessive text output). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNext problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44356\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Orthos\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStatistics on solutions submitted as at 15 October 2017:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFastest wall time to decode 5000 messages = 93 milliseconds\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1279303\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with a size-based score of 40.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSmallest size-based score = 38\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1278780\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1278780\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, for which wall time to decode 5000 messages = 515 milliseconds.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBest combined score = 49, for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351-code-breaker-part-i-operation-phoenix/solutions/1279303\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eSolution 1279303\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45211,"title":"AES SubBytes() Transformation","description":"Given a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm SubBytes() transformation and output a 16x2 character hexadecimal array. \r\n\r\nRefer to this link: \u003chttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003e\r\n\r\nFor example:\r\n\r\n  statei=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\n  stateo=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2'];","description_html":"\u003cp\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm SubBytes() transformation and output a 16x2 character hexadecimal array.\u003c/p\u003e\u003cp\u003eRefer to this link: \u003ca href = \"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\"\u003ehttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003estatei=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateo=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2'];\r\n\u003c/pre\u003e","function_template":"function stateO = SubBytes(stateI)\r\n  stateO = stateI;\r\nend","test_suite":"%%\r\nstateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateO=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n%%\r\nstateI=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2']; \r\nstateO=['82';'c5';'61';'d4';'70';'4c';'37';'c5';'cb';'08';'4a';'1c';'82';'08';'a8';'3a']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n%%\r\nstateI=['82';'c5';'61';'d4';'70';'4c';'37';'c5';'cb';'08';'4a';'1c';'82';'08';'a8';'3a']; \r\nstateO=['13';'a6';'ef';'48';'51';'29';'9a';'a6';'1f';'30';'d6';'9c';'13';'30';'c2';'80']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n%%\r\nstateI=['13';'a6';'ef';'48';'51';'29';'9a';'a6';'1f';'30';'d6';'9c';'13';'30';'c2';'80']; \r\nstateO=['7d';'24';'df';'52';'d1';'a5';'b8';'24';'c0';'04';'f6';'de';'7d';'04';'25';'cd']; \r\nassert(isequal(SubBytes(stateI),stateO))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-21T17:35:28.000Z","updated_at":"2025-12-28T04:07:40.000Z","published_at":"2019-11-21T17:45:04.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm SubBytes() transformation and output a 16x2 character hexadecimal array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRefer to this link:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[statei=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\\nstateo=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2'];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44356,"title":"Code breaker, Part II:  Operation Orthos","description":"You have been tasked with decoding several batches of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).  \r\n\r\nYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \"Operation Orthos\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation.  Therefore you should seek _simultaneous_ occurrence of the separate words \"Operation\" and \"Orthos\" (with any capitalisation) in messages within the given batch.  \r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e];  (2)  the decoded messages [as a \u003chttp://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta cell array\u003e (containing \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e)].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".  \r\n\r\nEXAMPLE\r\n\r\nSuppose the batch contained two encoded messages — _\"qspdffe x/ pqfsbujpo\"_ and _\"Psuipt jt HP!\"_ (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the original messages would have been:  _\"proceed w/ operation\"_ and _\"Orthos is GO!\"_ .\r\n\r\nThe correct answer would comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = {'proceed w/ operation', 'Orthos is GO!'}\r\n\r\nIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar' \u003chttp://au.mathworks.com/help/matlab/ref/nan.html NaN\u003e in both fields (no need for a cell array).  \r\n\r\n|Note:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".  \r\n\r\n----------\r\n\r\nPrevious problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351 Operation Phoenix\u003e.  Next problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44383 Operation Xiangliu\u003e.","description_html":"\u003cp\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026 numbers) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).\u003c/p\u003e\u003cp\u003eYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \"Operation Orthos\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation.  Therefore you should seek \u003ci\u003esimultaneous\u003c/i\u003e occurrence of the separate words \"Operation\" and \"Orthos\" (with any capitalisation) in messages within the given batch.\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e:  (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e];  (2)  the decoded messages [as a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\"\u003ecell array\u003c/a\u003e (containing \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e)].  \r\nThe name of the structure array shall be \"s\", with respective fields \"shift\" and \"message\".\u003c/p\u003e\u003cp\u003eEXAMPLE\u003c/p\u003e\u003cp\u003eSuppose the batch contained two encoded messages — \u003ci\u003e\"qspdffe x/ pqfsbujpo\"\u003c/i\u003e and \u003ci\u003e\"Psuipt jt HP!\"\u003c/i\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  (Note that the shifting 'wraps' back around.)  \r\nThus the original messages would have been:  \u003ci\u003e\"proceed w/ operation\"\u003c/i\u003e and \u003ci\u003e\"Orthos is GO!\"\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eThe correct answer would comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = {'proceed w/ operation', 'Orthos is GO!'}\r\n\u003c/pre\u003e\u003cp\u003eIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar' \u003ca href = \"http://au.mathworks.com/help/matlab/ref/nan.html\"\u003eNaN\u003c/a\u003e in both fields (no need for a cell array).\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003ePrevious problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351\"\u003eOperation Phoenix\u003c/a\u003e.  Next problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44383\"\u003eOperation Xiangliu\u003c/a\u003e.\u003c/p\u003e","function_template":"function s = decode(x)\r\n  s = x;\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions, \r\n% so the assessment of your submission may therefore change over time.  \r\nRE = regexp(fileread('decode.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'assert', 'freepass', 'tic'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any(  cellfun( @(z) ismember(z, tabooWords), RE )  ), msg)\r\n\r\n\r\n%% Test 1\r\nx =                 {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};\r\ns_correct.shift = uint8(1);\r\ns_correct.message = {'proceed w/ operation', 'Orthos is GO!'};\r\ns = decode(x);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message{1}, s_correct.message{1}) )\r\nassert( isequal(s.message{2}, s_correct.message{2}) )\r\nassert( isequal(s.message, s_correct.message) )\r\nassert( isequal(s, s_correct) )\r\nassert( isequal(class(s.shift), 'uint8') )\r\nassert( isequal(class(s.message), 'cell') )\r\nassert( isequal(class(s.message{1}), 'char') )\r\n\r\n\r\n%% Test 2\r\nx =                 {'Hfqq Ons ts 555-7839 FXFU.', 'twymtx nx ts mtqi', 'bfnynsl ktw dtzw fianhj', 'TUJWFYNTS UTXYUTSJI'};\r\ns_correct.shift = uint8(5);\r\ns_correct.message = {'Call Jin on 555-7839 ASAP.', 'orthos is on hold', 'waiting for your advice', 'OPERATION POSTPONED'};\r\ns = decode(x);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 3\r\nx =                 {'Ocz kvnnrjmy rvn xcvibzy: \"Knpdko\" oj \"Gjlzgk\".', 'Jkzmvodji Kcjzids rvn npxxznnapg. Izso rdgg wz Jmocjn.', 'Edi Uvkxgzout rdgg wz gzvydib Ozvh V'};\r\ns_correct.shift = uint8(21);\r\ns_correct.message = {'The password was changed: \"Psuipt\" to \"Loqelp\".', 'Operation Phoenix was successful. Next will be Orthos.', 'Jin Zapcletzy will be leading Team A'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 4\r\nx =                 {'bxmzzuzs r/ adftae az fdmow', 'adftae etxp oaybxqfq uz 2 iwe', 'abqdmfuaz pmfq eturfqp nmow 2 p.', 'naawe dqoquhqp. fwe Vuz' };\r\ns_correct.shift = uint8(12);\r\ns_correct.message = {'planning f/ orthos on track', 'orthos shld complete in 2 wks', 'operation date shifted back 2 d.', 'books received. tks Jin'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 5\r\nx =                 {'Hdsffafy xgj Ghwjslagf Gjlzgk zsk gxxauasddq ugeewfuwv.  Lzak oadd tw dwv tq Lwse S, kmhhgjlwv tq Lwse T sk fwwvwv.'};\r\ns_correct.shift = uint8(18);\r\ns_correct.message = {'Planning for Operation Orthos has officially commenced.  This will be led by Team A, supported by Team B as needed.'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% Test 6\r\nx = {'Mncpyrgml Nfmclgv qryprcb rfpcc bywq yem.  Yjj ncpqmllcj ypc rm pckygl ml bsrw slrgj Mncpyrgml Nfmclgv gq amknjcrcb.'};\r\ns_correct.shift = nan;\r\ns_correct.message = nan;\r\ns = decode(x);\r\nassert( isnan(s.shift) )\r\nassert( isnan(s.message) )\r\n\r\n\r\n%% Test 7\r\nx =                 {'Iutloxskj vgyycuxj oy tuc \"Ruwkrv\".', 'Vrgt lux uxznuy ruuqy UQ, haz tkkj suxk $$$', 'Ksgor Pot Fgvirkzfe ut xacqxb@sgzncuxqy.ius xk. Zakyjge', 'Zgrqkj zu Zkgs H.  Ngvve zu yavvuxz uvkxgzout....', 'Xk. latjy, vry zxgtylkx zu giiuatz \"YZOBKDSYX\" - ZDY', 'jUT''Z cUXXE'};\r\ns_correct.shift = uint8(6);\r\ns_correct.message = {'Confirmed password is now \"Loqelp\".', 'Plan for orthos looks OK, but need more $$$', 'Email Jin Zapcletzy on ruwkrv@mathworks.com re. Tuesday', 'Talked to Team B.  Happy to support operation....', 'Re. funds, pls transfer to account \"STIVEXMSR\" - TXS', 'dON''T wORRY'};\r\ns = decode(x);\r\nassert( isequal(s.shift, s_correct.shift) )\r\nassert( isequal(s.message, s_correct.message) )\r\n\r\n\r\n%% TIMING \r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Acknowledgements  \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% INITIALISE\r\nx = {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};\r\nqSmall = 50;\r\nqBig = 10000;\r\n%cutoffTimeBig = 10;\r\n\r\n% EDIT (2018-06-17).  Reduced time to pose reasonable challenge.\r\n% Accounted for improving Cody server speed per Problem 44655.\r\ncutoffTimeBig = 3;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\ntRef = datetime('2018-06-17', 'InputFormat','yyyy-MM-dd');\r\ntNow = datetime('now');\r\nyearsElapsed = (datenum(tNow) - datenum(tRef)) / 365.24;\r\nfprintf('\\r\\n\\r\\n\\r\\nSubmission evaluated for speed on %s.\\r\\n', datestr(tNow, 'dd mmmm yyyy'))\r\nrInf = 0.2;   delta = cutoffTimeBig - rInf;  tau = 3.6;  % Data from Problem 44655, based on Problem 963.\r\nqBig = floor( qBig * (cutoffTimeBig - rInf) * exp(yearsElapsed/tau) / delta );\r\nfprintf('\\r\\n\\r\\n\\r\\nTo account for computational power increases over time, number of iterations increased to %u.\\r\\n', qBig)\r\n% END EDIT (2018-06-17)\r\n\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\n\r\n% *** PRELIMINARY TIMING WITH timeit ***\r\nfDecode = @()   decode(x);\r\ndt_timeit = timeit( fDecode );\r\nfprintf('APPROXIMATE time to decode %u message batches ~ %2.2f seconds, according to ''timeit''.\\n\\r', qBig, dt_timeit * qBig)\r\n\r\n% *** PRELIMINARY TIMING WITH SHORT LOOP ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\ndisp('     -----=====-----     ')\r\n%fprintf('Your wall time to decode %u message batches = %i seconds.\\n\\r', qSmall, floor(dt))\r\nfprintf('APPROXIMATE wall time to decode %u message batches ~ %2.2f seconds, by extrapolating from %u batches.\\n\\r', qBig, dt * qBig / qSmall, qSmall)\r\ndisp('     -----=====-----     ')\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    solution = decode( x );\r\nend;\r\n\r\n% Compute and display elapsed time.\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\ndisp('     -----=====|||||=====-----     ')\r\ndt = etime(clock, t0);\r\nfprintf('Your wall time to decode %u message batches = %2.2f seconds.\\n\\r', qBig, dt)\r\n\r\ndt_cpu = (cputime - t0_cpu);\r\nfprintf(' ( Your CPU time for this = %2.2f seconds. ) \\n\\r', dt_cpu)\r\n\r\n% Display (default) Cody size-based score.\r\nall_nodes = mtree('decode.m', '-file');\r\nsize_score = count(all_nodes);\r\nfprintf('Your Cody-standard size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score\r\ncombinedScore = size_score + round(dt * 10);\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW.  It must be able to finish within %u seconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig )","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":29,"test_suite_updated_at":"2018-06-17T14:03:55.000Z","rescore_all_solutions":false,"group_id":40,"created_at":"2017-10-03T06:52:32.000Z","updated_at":"2026-04-02T18:15:25.000Z","published_at":"2017-10-03T11:50:21.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation \u0026amp; numbers) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and may vary between batches of messages — although it will be the same for all messages in a batch (also, here you need to decode, not encode).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou can also assume that the original batch of messages will relate to an activity that is referred to by those involved as \\\"Operation Orthos\\\". However, in their secret internal communications they might not use this exact phrase at all, nor this exact capitalisation. Therefore you should seek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esimultaneous\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e occurrence of the separate words \\\"Operation\\\" and \\\"Orthos\\\" (with any capitalisation) in messages within the given batch.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to crack the codes and report back in a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e]; (2) the decoded messages [as a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ecell array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (containing\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e)]. The name of the structure array shall be \\\"s\\\", with respective fields \\\"shift\\\" and \\\"message\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained two encoded messages —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"qspdffe x/ pqfsbujpo\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Psuipt jt HP!\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. (Note that the shifting 'wraps' back around.) Thus the original messages would have been: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"proceed w/ operation\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Orthos is GO!\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(1)  \\ns.message = {'proceed w/ operation', 'Orthos is GO!'}]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the batch of messages cannot be decoded when following the above assumptions, then simply return 'scalar'\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/nan.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eNaN\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e in both fields (no need for a cell array).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Phoenix\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44383\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Xiangliu\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":78,"title":"Implement a ROT13 cipher","description":"Replace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if necessary). So A ? N, B ? O, and so on until Y ? L and Z ? M. Case of the output should match the case of the input, so a ? n. Non-alphabetic characters are left in place and untouched.\n\nIf\n\n s1 = 'I love MATLAB'\n\nthen\n\n s2 = 'V ybir ZNGYNO'\n\nSee the \u003chttp://en.wikipedia.org/wiki/ROT13 Wikipedia article\u003e for more info.","description_html":"\u003cp\u003eReplace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if necessary). So A ? N, B ? O, and so on until Y ? L and Z ? M. Case of the output should match the case of the input, so a ? n. Non-alphabetic characters are left in place and untouched.\u003c/p\u003e\u003cp\u003eIf\u003c/p\u003e\u003cpre\u003e s1 = 'I love MATLAB'\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre\u003e s2 = 'V ybir ZNGYNO'\u003c/pre\u003e\u003cp\u003eSee the \u003ca href=\"http://en.wikipedia.org/wiki/ROT13\"\u003eWikipedia article\u003c/a\u003e for more info.\u003c/p\u003e","function_template":"function s2 = rot13(s1)\n  s2 = s1;\nend","test_suite":"%% Test #1\n\ns1 = 'I love MATLAB';\ns2_correct = 'V ybir ZNGYNO';\nassert(isequal(rot13(s1),s2_correct))\n\n%% Test #2\n\ns1 = 'I \u003c3 MATLAB!!';\ns2_correct = 'V \u003c3 ZNGYNO!!';\nassert(isequal(rot13(s1),s2_correct))\n\n%% Test #3\n\ns1 = 'The quick fox stumbled over the confusing instructions.';\ns2_correct = 'Gur dhvpx sbk fghzoyrq bire gur pbashfvat vafgehpgvbaf.';\nassert(isequal(rot13(s1),s2_correct))\n\n%% Test #4\n\ns1 = 'Snape kills Dumbledore on page 606. Also, there is no Santa.';\ns2_correct = 'Fancr xvyyf Qhzoyrqber ba cntr 606. Nyfb, gurer vf ab Fnagn.';\nassert(isequal(rot13(s1),s2_correct))\n\n","published":true,"deleted":false,"likes_count":13,"comments_count":3,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1713,"test_suite_updated_at":"2012-01-18T01:00:28.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:28.000Z","updated_at":"2026-01-06T04:39:32.000Z","published_at":"2012-01-18T01:00:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReplace each character in string s1 with the character that is shifted 13 positions from it (wrap back to the beginning if necessary). So A ? N, B ? O, and so on until Y ? L and Z ? M. Case of the output should match the case of the input, so a ? n. Non-alphabetic characters are left in place and untouched.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ s1 = 'I love MATLAB']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ s2 = 'V ybir ZNGYNO']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia article\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for more info.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44961,"title":"RSA decryption","description":"Decrypt a large integer string using RSA decryption given the public key (n) and private key (d). Convert the large integer decryption into an output message string with UTF-8 representation.\r\n\r\nExample:\r\n\r\n encrypted_message = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%input\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%input\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';%input\r\ndecrypted_message = 'I like to swim!';%output\r\n\r\n\r\n","description_html":"\u003cp\u003eDecrypt a large integer string using RSA decryption given the public key (n) and private key (d). Convert the large integer decryption into an output message string with UTF-8 representation.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e encrypted_message = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%input\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%input\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';%input\r\ndecrypted_message = 'I like to swim!';%output\u003c/pre\u003e","function_template":"function decrypted_message = RSA_Decrypt(encrypted_message,d,n)\r\n  decrypted_message = 'I like to swim!';\r\nend","test_suite":"%%\r\nm='158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';\r\nmessage = 'I like to swim!';\r\nassert(isequal(RSA_Decrypt(m,d,n),message))\r\n%%\r\nm='99761240327251194937668282784881225946299704960682605372368300120848092908591455333889649815054891832920433772438140697229743047905660648016064750862552787515723449901585029566883857331537912668878918706229773460108043130645834201085405226084010413433457258525704626839479467337463012332940952234541291286602023412313079939518264986360860440514106228995186076871512459300140814669747884371890194124';\r\nn='2044371069952561243871813747701535503388267616657953475148898181142012590397809234167373308955772082860082985954286137615597515257087506574051530104475374974920093127841789408014496870693507622812332673504654584870100580476794800708440785082437228308551107726064054828640053321250498545183042994878498928173976370185712833904492317580152665428272199317847097773542066059565512439224992672101163367819';\r\nd='131358569595346680469722564224349085322306406056832660693226883146757023027681686453130430199929142940992255578581548217026735077095312421736286269892515739496597527524021166625708322359741224036234988705082882699895245449017415856831226734459122764117157172961113990706104659539690141481103935528273973382371183154438463086325519326121228923730136467766036183357672350586091588640276470994058874793';\r\nmessage = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nout=RSA_Decrypt(m,n,d);\r\nassert(isequal(RSA_Decrypt(m,d,n),message))\r\n%%\r\nm='23055330962704323769878549529115024711681463755869375992447358448257597289666397997393945478297323372847937346015110864832142828615195632399869833059964395947034849804307978652470092440225822549097020437344501330227622390881049097656181781980124142659454562923055085607225529541369345564097544873012395850084756321027482195140106724706102857159831541577386517426252851135917933602432485339455137853480425755360413522537180403768732770990453717801905433194599201771294559164174484366213507079896512750859909040228686293902666244968559905065091421969981123917913807285202549025830873320919273470513619143052127674709353494599047667391749001044180280253098309127910967801244777547067797257847396027373615105278074126621948502699483945442597921239032762535839481741386676784123570880434889025648597593711911259097408384527597630246903648267481820555872340696607290773027177673329986283293168575528258578575033034179306629426942699054620008867304832513427178319015491321861291086200676826846740503213061372327825278234127270730394825241275398344604061667061892125034848354745243512927194104643800196788262228848172689053393410972717679060779374106225778531311917434399927265718394014531619654762559111657295163989321031700962115070401533540746801357628868609255941469541707984326602981168016264720519340003693219403163278843126513912057794102645161814569893320900148891952732032827189210372803453777673309727629845360314416264926243414888253428149538146304399700653423118791724424837155323935319171814705469113037576054893140065594406360362408167462563925199225169055130480445976569760198217276692195730775524801021060293503580957364539210146595506177369243830063105693396808209631409860229448190041996912370291877581261016834769083953407597967437841733812344230896457097759403613339974363380556576775192238298546579676296359906794868505900966056565863994904406875527092603782089107591766239203672780399852597928423220774857864301715176837587724591257928112610743311445186658958007825888475800717425136849205837547536117562642680';\r\nn='44842008376687803367401704855862174057751658874412319214254366772513580664834338103711248053800336314605433363839051280089244765499067546768593375603554906634041005882836398715141891796137918851678901692978242458027064144613729242304549721699241688731628849316717564354846304644497408201649639245333007226999680183209765262168096747256549932760714835163829498814356014506466022681051474161134416048209239076204778228261950266231966892099194904195589855692846886804440024833800891898474520523721428667143505915995217245366095168045283186412220277535584022415882288464175935131208288146822299727657938865855853054174274144036081729604573534323903573564345990066095029031133576597298513883268061041004553754062342541175017746399640362184228727837219293246060058323563065371426108553463224921179093569734439828568435658070810483844709529476015493154462587917722806971578721201741643550136095893915598053953011321347017522943202801820158823344592288227452688958887872572522782675644714289349442555731461112275849176682816627205790162163242534462778708459909915826953853537650009043468930450287584181263070727575137424307931682948818963610116434419852585517456098152109913486868606969385133300794635427715727859479612757775192862801547635779921771426233897718528292667112148507798722127322607462037572360649156150337532940752245966765201596748120586383127825681873289878451591957019880886587602576426267683951317718936847177641679183717321862429721190212389237395890951104472937261743929446841800523276218816808066432194473964294708564511969507018959711475230849760902049071415838600456901108854663197095849833602808088094456341330276320302662577163562657750920481798540333412112880539002713127873625438212479154166226846436038698572615482646490520911334607730484144343834476612603467400722323562384577281087071440008144012534847478593412147312743274523095010025887231371129897419306984829625295595332434377173711414555784685658774002600022998291909172576630780759729269867715816511099791566815282862210319017784751883446582453959';\r\nd='6565816445407878925089441991498747612160839198603241148969054176252198301108538816900577327681584864655900309129187116952811278662878254707896639032786256375181309679291058212467790617143590175026484896254317631677185521639888090836542092702228103896557828982761215001435908561096741216458335569193212038242350596427680660630865867932219252556141104387324837429582683296520255026128293117631961432452139374326884841820676484348718346835892309697741432400454075190738155214690226263908349465883864526754491093121291860880617807231984031261908018115438062149668224668541927056762969514272957080528641551440449912383177971011340773567381595669197227397095749281691989236351340479846140946699426488082757798251098448588056674770754671643802109836061405587518383808732642252532232749119323532411226969424472963287039513173436339822906642733903667734412972727748722945805719038892729473535651253460092450459024621811281873600606895132005494130257832946742084673535377347237875132451694131873556170785954511701761479583203082125987308962572083138475191433479413530168163642321800669575367485309537509082240852273955663933547032858727060003363699057579114677450927657082252183166216411898446363400905797006665507108575986344278988745322935954278566001664060256959781130851422164231215979527541890717097899466088129536122753240075629363188908753526503257284825826946057815889269456925910606842810401392503996936381736547569711529540423604489529836981870198914784848089842823822656591932437295439032050213520000125621624734133380868707883468507784350355251698659006842220673722867592264770652693364873913361956132623339827358272992906883218249723187904101702943978747751691915678242891407493339828656260188711974558580485287404900248093520605466868886511014909072710668999090169680693653605673085931199903788603401848851956524927526592113342563256817891019122155938256416456381627581783190684277329685396205824988569434587069719626936811661218907123975873968219302538615272967013401476757929690613750478379916399826582503908605565505';\r\nmessage = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nout=RSA_Decrypt(m,n,d);\r\nassert(isequal(RSA_Decrypt(m,d,n),message))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":"2019-09-08T23:48:25.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-08-29T18:26:28.000Z","updated_at":"2025-10-15T14:51:55.000Z","published_at":"2019-09-05T14:41:54.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDecrypt a large integer string using RSA decryption given the public key (n) and private key (d). Convert the large integer decryption into an output message string with UTF-8 representation.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ encrypted_message = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%input\\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%input\\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';%input\\ndecrypted_message = 'I like to swim!';%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44963,"title":"Mask Generation Function (MGF1) for PKCS #1 Standard utilizing Optimal Asymmetric Encryption Padding for RSA Cryptography","description":"Create Mask Generation Function (MGF1) from PKCS #1 v2.2 standard (B.2.1 page 50) at below link. Input will be character array (mgfSeed) which will need to be converted to octet array using UTF-8 representation. Output must be octet array (uint8) of length, maskLen (input). Hashing must use SHA-1 (160 - 20 byte).\r\n\r\nFor example:\r\n\r\n  mgfSeed = 'I like to swim.';%input\r\n  maskLen = 20;%input\r\n  mask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];%output\r\n\r\n\r\n\u003chttps://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 194px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97px; transform-origin: 407px 97px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCreate Mask Generation Function (MGF1) from PKCS #1 v2.2 standard (B.2.1) at below link. Input will be character array (mgfSeed) which will need to be converted to octet array using UTF-8 representation. Output must be octet array (uint8) of length, maskLen (input). Hashing must use SHA-1 (160 - 20 byte).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 60px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30px; transform-origin: 404px 30px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003emgfSeed = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'I like to swim.'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003emaskLen = 20;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003emask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%output\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function mask = mgf(mgfSeed,maskLen)\r\n    mask = []%octet array of length maskLen\r\nend","test_suite":"%%\r\nmgfSeed = 'I like to swim.';\r\nmaskLen = 20;\r\nmask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];\r\nassert(isequal(mgf(mgfSeed,maskLen),mask))\r\n%%\r\nmgfSeed = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nmaskLen = 825;\r\nmask = [40    55   251    83   143   211    49    16    87    56   109   116    17   188    72    54   231    67   125   182   223    53   149    36   246   233    71   113   113    29   176    61    74    77   205   167   179    99   172   172   212   249    53   148    13    89   253     3    85     0   155   181    94    15     8   122   120    92    29   229   229    46   192   162   252   119   243    94    52    12   133    98   161   249   152    68    69    22 156   155   229   132    30   163   102    90   217   160    36    53   185   128    74   224   105   214   134    90   188   101    98   220    43   162   251   183    72    54   219     4    44   185   199   193    31    42   129   112    74    25    81   133    70   156    38   225   243    24    50   132    79   130    42    72   145   158   105   253   190    62    73   107    95   133    78   238   214    39    88   245    40    46   166   201   173   209   234   194     3   117   226    32   176    12   139    83   211    67   101    99   174   126   103   130    83    56   157    52    76    21   189    99   217    43   150    92   219   148   173   138   184   183   203    62   231   125    42    79    29   248    30    26   127    50     9    31   219   212   160   157   243    15    52   217     7   144    43   241    70    98   247   231   174   111    96    91   108    59   164   146    77   180   212   155   165    18   150   198   100   233   255   129    44   170   150   243   244   126   203   255   231    28    94    77    58   198   147    84   212   248    36    34   107   210    77    79    80   224    24   126    88   125   255    11   124   227    44   253   242   234    59   176   108   146   170   132    20   128   230   141   187    81   139    26   119    47   159     8   182    40    94   213   107   223    21   187    35     1    40   145   154    92   218   252    46   201   203    65    48    94   118   110     5   158   212    19   129     9    59   124    19   190   201    55   141   124   210    85   240    34   150    81   154    11     3   116   204    37    73    39   169   234    50   241   131    94     9   133     0   209   190   171   206    93   165   145   142   117   230    34   245   223   205   153   227   202     3   218    56   163   203   137    46   114    78   248   196   136    19   177   126    95   231   213   251   130    39    57    59   228   251    73    48     9   109    11   172   152   223   120   153   108   233    76   117   219     8     6   124    44     7   249   116    43   198    98    55   235    52    47   146   239    76   142    88    19    64   169   209   206   255   101    91   197    36   180   253    52    54    63   198    63   113    58    43   229   141    59     4   147    34   200     7   184   108   176   153    95    94    18   235   178   160    51    63   154   227    39   231    71   246   109    13   199   185   220   180    50   146    85   194   176   175   159   103   177    47   149   252   182    33   224   226     1   232   167    94    93   202    55    60   201   228   107   135   142    22   165   168   124   219   216    34   230   174   179    66    67    91    92   186    30    48     9   177   192   254   190   236    52    84   114   255     3    81   150   112   131    49   157    48   243   218    11   132    40    13    68   214   159    36   109   152   219    32   219   193   182    69    37   104   217   115    54   158    79    90     3   223   116   127     8    28   233   223   194    30   241   180    45   209    77   180   184    52   132   164    49   206    50    57   149   118   105    44    25   212   141   253   150    45   244    73   203    10   137   161   118    49   165   248   105   215    58    90    67   180    78    22   135   102   173   139    62    31    63    82   187    78    47     2   176   144    83    22   143    31   155     8   160    12   252   164    52   159   102   113    95   132    49   168   194   137    32   131   189   139    77   143   248    36    30   154   239   163   149    86     9   178   122     6   248    25   208   211   142    59    23    72    43   158   195   244   232   229   245   148    49   163    28    81    93   106    33   239   249    26   220    73    65   112   249   254   251    91   106   204   113    10    59    34   114   189   185   188   181   100   185    22   188   221   187   109   170    35    57   181   234   157   230   206   169    97   140    51   170   128   215   188    14    50   190   167    41   173    19    10    98   165    12    77    49    21    33   147    93    84   163   106   151   234    76   252    91   165   248   223   136    85   124   174    90   188   130   174    83    92   181   134    65    91   105    15   103    91    15    27   201   162    58    84   164    33   137    63     0    84     0    78   180    31   218    47    84    43    13    35   122   117   205    59    81   146    97    14];\r\nassert(isequal(mgf(mgfSeed,maskLen),mask))\r\n%%\r\nmgfSeed = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nmaskLen = 300;\r\nmask = [96   185   223   209   149    51   224   128   249   139    57   249   190    69   199   132    37    24    75   127    98    59   231   206    13    83    79   111   181   220   204   120    27   178   155   116   155    11   157   112    10   195   106     4   127   146   101   112   197    29    54    45    14    78    16   100     1   111   156    44   138   141   219   101   171     1   126   254    60    82   214    63    13    94   227   238    64   173    93   142     3   224    63    76     8   190   105     8    77   113   250   243   249    82    56   124   129   116   121   131   207   116    80   185    72   184   244   232   236   127    37   195   236   163   176   245    65    48   169   131    19    36   208   178   184   150   188    50   221    83   132   241    73   205    23     9    41    74    65   251    10    21   133   150   101    15    42   153   164   197   136    19   113   134   153   247    10   161   221   184   195   215   253   149   223    83   180   148   198     4    53   112   114    39    18   132   254   170   130    61     6   158   224   166    76   187   190   128    14   251   158   218   192    68    46   210   199   231   120    57   212    10   107     2    50    37   110    30    87    48     2   134    81   165   107    95   250   206    98    26    45   102   173    46    85   103   137     4   140   154   236   142   125   211    28   164    94    41     8    70   215    10    13   140   139    97   205    60   212   205    35   175   235   158    88   165    40    41   187   215    72   172    97   159   119    79    80    31   128   121   108    94   219   216    77   209   184   244    90   238   182   207   244    52   248     6   220   175   117   122   236   228   219    42    49   196   186    12    19    95];\r\nassert(isequal(mgf(mgfSeed,maskLen),mask))","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-09-06T22:10:21.000Z","updated_at":"2025-10-15T14:43:51.000Z","published_at":"2019-09-06T22:31:17.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate Mask Generation Function (MGF1) from PKCS #1 v2.2 standard (B.2.1) at below link. Input will be character array (mgfSeed) which will need to be converted to octet array using UTF-8 representation. Output must be octet array (uint8) of length, maskLen (input). Hashing must use SHA-1 (160 - 20 byte).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[mgfSeed = 'I like to swim.';%input\\nmaskLen = 20;%input\\nmask = [170,251,101,210,23,101,10,242,193,163,174,148,104,138,228,245,52,234,0,195];%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44959,"title":"RSA encryption using public key ","description":"Encrypt the message text by converting to uint8 matrix using UTF-8 representation. Convert uint8 matrix to a large integer string. Use RSA encryption on the integer string given the public keys (n and e) and output the encrypted integer string. The public key (e) will always be fixed at 65537. No hashing or padding of the message is done.\r\n\r\nFor example:\r\n\r\n  message = 'I like to swim!';%given as input\r\n  integer_String = '379695297047669462525290688599911713';%calculated\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%given as input\r\ne= 65537;%fixed\r\noutput_String = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%output\r\n\r\nSee:\r\n\u003chttps://simple.wikipedia.org/wiki/RSA_algorithm\u003e\r\n","description_html":"\u003cp\u003eEncrypt the message text by converting to uint8 matrix using UTF-8 representation. Convert uint8 matrix to a large integer string. Use RSA encryption on the integer string given the public keys (n and e) and output the encrypted integer string. The public key (e) will always be fixed at 65537. No hashing or padding of the message is done.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003emessage = 'I like to swim!';%given as input\r\ninteger_String = '379695297047669462525290688599911713';%calculated\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%given as input\r\ne= 65537;%fixed\r\noutput_String = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%output\r\n\u003c/pre\u003e\u003cp\u003eSee: \u003ca href = \"https://simple.wikipedia.org/wiki/RSA_algorithm\"\u003ehttps://simple.wikipedia.org/wiki/RSA_algorithm\u003c/a\u003e\u003c/p\u003e","function_template":"function encrypted_message = RSA_Encrypt(message,n)\r\n  encrypted_message='14133';\r\nend","test_suite":"%%\r\nmessage = 'I like to swim!';\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';\r\nout = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';\r\nassert(isequal(RSA_Encrypt(message,n),out))\r\n%%\r\nmessage = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nn='44842008376687803367401704855862174057751658874412319214254366772513580664834338103711248053800336314605433363839051280089244765499067546768593375603554906634041005882836398715141891796137918851678901692978242458027064144613729242304549721699241688731628849316717564354846304644497408201649639245333007226999680183209765262168096747256549932760714835163829498814356014506466022681051474161134416048209239076204778228261950266231966892099194904195589855692846886804440024833800891898474520523721428667143505915995217245366095168045283186412220277535584022415882288464175935131208288146822299727657938865855853054174274144036081729604573534323903573564345990066095029031133576597298513883268061041004553754062342541175017746399640362184228727837219293246060058323563065371426108553463224921179093569734439828568435658070810483844709529476015493154462587917722806971578721201741643550136095893915598053953011321347017522943202801820158823344592288227452688958887872572522782675644714289349442555731461112275849176682816627205790162163242534462778708459909915826953853537650009043468930450287584181263070727575137424307931682948818963610116434419852585517456098152109913486868606969385133300794635427715727859479612757775192862801547635779921771426233897718528292667112148507798722127322607462037572360649156150337532940752245966765201596748120586383127825681873289878451591957019880886587602576426267683951317718936847177641679183717321862429721190212389237395890951104472937261743929446841800523276218816808066432194473964294708564511969507018959711475230849760902049071415838600456901108854663197095849833602808088094456341330276320302662577163562657750920481798540333412112880539002713127873625438212479154166226846436038698572615482646490520911334607730484144343834476612603467400722323562384577281087071440008144012534847478593412147312743274523095010025887231371129897419306984829625295595332434377173711414555784685658774002600022998291909172576630780759729269867715816511099791566815282862210319017784751883446582453959';\r\nout = '23055330962704323769878549529115024711681463755869375992447358448257597289666397997393945478297323372847937346015110864832142828615195632399869833059964395947034849804307978652470092440225822549097020437344501330227622390881049097656181781980124142659454562923055085607225529541369345564097544873012395850084756321027482195140106724706102857159831541577386517426252851135917933602432485339455137853480425755360413522537180403768732770990453717801905433194599201771294559164174484366213507079896512750859909040228686293902666244968559905065091421969981123917913807285202549025830873320919273470513619143052127674709353494599047667391749001044180280253098309127910967801244777547067797257847396027373615105278074126621948502699483945442597921239032762535839481741386676784123570880434889025648597593711911259097408384527597630246903648267481820555872340696607290773027177673329986283293168575528258578575033034179306629426942699054620008867304832513427178319015491321861291086200676826846740503213061372327825278234127270730394825241275398344604061667061892125034848354745243512927194104643800196788262228848172689053393410972717679060779374106225778531311917434399927265718394014531619654762559111657295163989321031700962115070401533540746801357628868609255941469541707984326602981168016264720519340003693219403163278843126513912057794102645161814569893320900148891952732032827189210372803453777673309727629845360314416264926243414888253428149538146304399700653423118791724424837155323935319171814705469113037576054893140065594406360362408167462563925199225169055130480445976569760198217276692195730775524801021060293503580957364539210146595506177369243830063105693396808209631409860229448190041996912370291877581261016834769083953407597967437841733812344230896457097759403613339974363380556576775192238298546579676296359906794868505900966056565863994904406875527092603782089107591766239203672780399852597928423220774857864301715176837587724591257928112610743311445186658958007825888475800717425136849205837547536117562642680';\r\nassert(isequal(RSA_Encrypt(message,n),out))\r\n%%\r\nmessage = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nn='2044371069952561243871813747701535503388267616657953475148898181142012590397809234167373308955772082860082985954286137615597515257087506574051530104475374974920093127841789408014496870693507622812332673504654584870100580476794800708440785082437228308551107726064054828640053321250498545183042994878498928173976370185712833904492317580152665428272199317847097773542066059565512439224992672101163367819';\r\nout = '99761240327251194937668282784881225946299704960682605372368300120848092908591455333889649815054891832920433772438140697229743047905660648016064750862552787515723449901585029566883857331537912668878918706229773460108043130645834201085405226084010413433457258525704626839479467337463012332940952234541291286602023412313079939518264986360860440514106228995186076871512459300140814669747884371890194124';\r\nassert(isequal(RSA_Encrypt(message,n),out))","published":true,"deleted":false,"likes_count":1,"comments_count":5,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":"2019-08-29T18:00:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-08-29T02:42:05.000Z","updated_at":"2025-10-15T14:57:07.000Z","published_at":"2019-08-29T02:52:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEncrypt the message text by converting to uint8 matrix using UTF-8 representation. Convert uint8 matrix to a large integer string. Use RSA encryption on the integer string given the public keys (n and e) and output the encrypted integer string. The public key (e) will always be fixed at 65537. No hashing or padding of the message is done.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[message = 'I like to swim!';%given as input\\ninteger_String = '379695297047669462525290688599911713';%calculated\\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';%given as input\\ne= 65537;%fixed\\noutput_String = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019';%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://simple.wikipedia.org/wiki/RSA_algorithm\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://simple.wikipedia.org/wiki/RSA_algorithm\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45213,"title":"AES-256 KeyExpansion()","description":"Given a 32-byte hexadecimal character array representing the AES-256 input key, execute the AES-256 algorithm, KeyExpansion() and output the xth (input) key-word of this 60-word sequence as a 4x2 hexadecimal array. You will need the SubBytes() function done in one of my previous Cody problems.\r\n\r\nRefer to this link: \u003chttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003e\r\n\r\nFor example:\r\n\r\n  key='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\r\n  x=58;%want key-word number 58 out of 60\r\n  w=['d0';'eb';'7c';'8a'];%58th key-word","description_html":"\u003cp\u003eGiven a 32-byte hexadecimal character array representing the AES-256 input key, execute the AES-256 algorithm, KeyExpansion() and output the xth (input) key-word of this 60-word sequence as a 4x2 hexadecimal array. You will need the SubBytes() function done in one of my previous Cody problems.\u003c/p\u003e\u003cp\u003eRefer to this link: \u003ca href = \"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\"\u003ehttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ekey='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\r\nx=58;%want key-word number 58 out of 60\r\nw=['d0';'eb';'7c';'8a'];%58th key-word\r\n\u003c/pre\u003e","function_template":"function w = KeyExpansion(key,x)\r\n  w = key;\r\nend","test_suite":"%%\r\nkey='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\r\nx=58;\r\nw=['d0';'eb';'7c';'8a'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='4b6b0490163a5b44345675ba437aec16eee63eee26643e0d2fe1f51eb8e0ca0b';\r\nx=31\r\nw=['da';'8d';'75';'fb'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='c0ad28b4cb90e11f5420fbfe9042b10f79e5a3adc1ca2fdb6c3e034a4ee79d4b';\r\nx=60;\r\nw=['38';'57';'bb';'18'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='b8b6426ab2dedb79f812fc5c2edb81e5a3fd5ef58a9dcbe728fcb93e36352969';\r\nx=10;\r\nw=['9d';'cd';'60';'16'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=7;\r\nw=['48';'d9';'78';'d8'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=57;\r\nw=['e3';'7d';'c6';'78'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=58;\r\nw=['cd';'9a';'06';'35'];\r\nassert(isequal(KeyExpansion(key,x),w))\r\n%%\r\nkey='7f837ce449b892bce32f99ba24f64c5f40ac117fc56e514f48d978d8a2e48999';\r\nx=59;\r\nw=['1e';'2b';'6e';'33'];\r\nassert(isequal(KeyExpansion(key,x),w))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-22T00:25:14.000Z","updated_at":"2025-10-11T16:12:13.000Z","published_at":"2019-11-22T01:37:11.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a 32-byte hexadecimal character array representing the AES-256 input key, execute the AES-256 algorithm, KeyExpansion() and output the xth (input) key-word of this 60-word sequence as a 4x2 hexadecimal array. You will need the SubBytes() function done in one of my previous Cody problems.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRefer to this link:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[key='e32868331fa8ef0138de0de85478346aec5e3912b6029ae71691c384237a3eeb';\\nx=58;%want key-word number 58 out of 60\\nw=['d0';'eb';'7c';'8a'];%58th key-word]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44964,"title":"Optimal Asymmetric Encryption Padding of message for RSA Cryptography ","description":"EME-OAEP encoding of input message using a Feistel network with SHA-1 hashing within the mask generation function (MGF1) (see problem 44963/below link 7.1.1 page 18). Inputs will include message (M), label (L), a random seed (seed) array of octets of length 20 (needed such that outputs can be compared), and output length (k). Output (EM) array will be an array of octets of length, k. Hash length will always be 20 for SHA-1 (160-20 bytes). The character length of input message will never exceed k-42.\r\n\r\nFor example:\r\n\r\n  M = 'I like to swim.';%input\r\n  L = 'abcdefghijklmnopqrstuvwxyz';%input\r\n  seed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];%input\r\n  k = 100;%input\r\n  EM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\r\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\r\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\r\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\r\n148,12,50,108,248,32,94];%output\r\n\r\n\u003chttps://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 356px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 178px; transform-origin: 407px 178px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eEME-OAEP encoding of input message using a Feistel network with SHA-1 hashing and mask generation function (MGF1) (see problem 44963/below link, section 9.1.1.1 (figure 1 shows the encoding process)). Inputs will include message (M), label (L), a random seed (seed) array of octets of length 20 (needed such that outputs can be compared), and output length (k). Output (EM) array will be an array of octets of length, k. Hash length will always be 20 from SHA-1 (160-20 bytes). The character length of input message will never exceed k-42.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 180px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 90px; transform-origin: 404px 90px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eM = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'I like to swim.'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eL = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'abcdefghijklmnopqrstuvwxyz'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ek = 100;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e148,12,50,108,248,32,94];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%output\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function EM = EMEOAEPencoding(M,L,seed,k)\r\n  EM = []%octet array of length k\r\nend","test_suite":"%%\r\nM = 'I like to swim.';\r\nL = 'abcdefghijklmnopqrstuvwxyz';\r\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\r\nk = 100;\r\nEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,148,12,50,108,248,32,94];\r\nassert(isequal(EMEOAEPencoding(M,L,seed,k),EM))\r\n%%\r\nM = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nL = '';\r\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\r\nk = 300;\r\nEM = [0   145   194    62    62   111    86   188    50    37   165   231    16    42    25    79   223   177   117   187   135   200   203   136   184   133    38   175    66    35   142   212   144   116    66    37   151     8   190   218    29   238   213    11   189   225    88    83   218   175   183    98    58   237    89    80   123    64    40   154   137    44    13   186    97   133    92    11   228    32   100   188    61    37   150   198   178    73   252    17   133   233    68    13    39    99     3   239   108   106   202   227   127   142    79    34   126   244    41    92   240     8   127   153   251    25    82    79   247    92   187    51    84    38   104   240    52   209   144   160   144   119   131    67   128   116    98   132    51    79     8   114    69   202    80   243   194    61    17    33   225   232   173     5   153   230    32   155    34    62    72     2   211   212   227     5   115   217    33   189    21   170    51   190   217   119   148    73   209   109   114    90   104   237   168    60   144   120   191     7   186     8   205   111   192   249   192   197    34   225   209   153   234     5    27   165    82    42   132   167   158    64   218   239    71    49   166    27    37     9   154     2   255   193    72    75     7   121   121   240    74   116   185    58    79   106    68    14    17    49    68    96   160     2    75    15   122   144    36    47   230   112    39   221    21   141   251   178    10   215   180   230   184   189   112   108   187    83    94   157    69   140   201    40   158   119    28   159   116   196   206   112    91   141    68   122   113   183    92   111    44   149   187   223   179   157    29    79   180   231    38   122   231    82    98    42    69    14   162    53];\r\nassert(isequal(EMEOAEPencoding(M,L,seed,k),EM))\r\n%%\r\nM = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nL = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\r\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];\r\nk = 825;\r\nEM = [0    85    82   177   212   151     6   148    36   245   178   209   163    30    35   103   231   155   104   206    51   230   201    47   178   114   199    15   172   217   175    58    48   240   133     0   186   218    10   200    31   238   213    10   237   132    55    35   182   202   151    21    82   130   121    35    14    35    75   255   236    72    45   210     0   243    57    43   137    79     9   217    83    81   227   171   156   105   168   121   224   201    41    98    85     6    35   155     4    15   179   195    12   251    44    65    27   145    77   112   208   124    23   252   219   116    61    61   146   124   207    91    49    95    72   135    85   191   228   128   228    24   163    48   245    23     1   225    86    43    40    19    43   174   112   135   170    88    49    76   142   154   200    37   237   142    69   226     2    88    33   108   183   244   130    37     4   184    88   157    97   197    19   205   172    20   247    44   180     9    92   122    59   132   197    85   252    25   205   107   195    36   237    24   168   156   174   229    81   142   188   252   133   107   126   133    59    89   164   193   255    41   182   134    41    86   138    59    81    97   255    34   139   164    38    47    98    23    26   137   106    29   202    26    59     5   100   105   116    69   100    15   206    34    42    47    30   255    83    65   145    17    85   185    53   254   139   219   120   182   216   198   204   213    17    24   155    48    63   243   101   233   191    77   240    87   126   250    23   171   163    21   123   236   100     9    20   219    58    66    74   224   215   185   218   241   113    38   218   128     6    10   149    61    18    66    32   109   219    27   107   176    90   163   116    99    71    16   108    89   192   253   121   121    76   157   101   157   217    51    53   248   195    95    93   183    71    29   199     2   182    31   120    35   167    44   189   160     2   154   234   162   113   204    18   138    81   155    86   122   147    44    23   181    90   135    49   235    41   194    82   181    31    45   131    78   127   198   121   132    49     6   186    66   157   159    79   110   184   152    83   107    73    61    22    86   160   156   200   177    64   217    32   251   102     4   165   143   254   215   165   224   110    76    57    69    13   198   180   106   236    11    39   238     0   220    63   109   239   190    19    85    92    23    28   183   233    72    88   193     8   101   127   214   171     7    94   156   148   220    40    84    44   149     7   245   165   150   197    27    93   255   146    15   132   133   174   208     4   156   246    12    37    50    78    85    95   212   198    41    22   138   214   135   145   197   137   114   172   128    48   126   202   198     0    35    15    37   127     1    34    44   164    46   131    12    87   254     9   210   140    50    85   180   173   121    24    14   192   237    75   224    91   242   205   155     8   136    51    38   161     6   129   234    36     1    56   251    11     6    73    36    74   230    95   174    47    94    53   106   142    71   123    88    32    41     7   108    41   101    40   120   254   196    47   251    83   224   181   114   255   127    56     6   182   182   153   244   162   214   115   183   162    69    47   174   112    68    89   110   180    43    47   159   195   123    73   230   230   186   204   129   110   234   218   152    57   154   232    91    68   237   204   222   179   175   192   249     1   128     5   180    93    29    14    97   175   138   175   221   223   219    62    93   142    51   123   194    90     6   215    32   181    60    48    92   100   114    28   164    71   110   244   129   190   125    27   156   223   133     7   128    55   127    93     3    21    66    38   184    50    52     6   164   175    17   255   103    42    28   126    66    19   149    66     6   234   170   194   104    85    42   166   171   117   101    33    74    35   181    46   242   102   192   226   183   132   223   154    97   142   119   107     6    98    93   129   255   247   144   159    12   245   161   179    28     1   228    24    38   147    55   148    10   247   224   154   201   241    32    53    23   219    52     0   124    35    47    36    89   180    68    57   183   240    94   235    86   152   105    26   113    72    38    83   194   138    16    45   187    50   207   192   151    54    80   108   139   211   116   186   176    20   250    32   117   237   241   239   224   147   110    22   190    71    59    47    97     8   144   236   102     8   216   238   225    40   212   181   238   106   223    38   121   175    55    54   194   114   234   213    89    36   150   177   249    96   235    51    12   205    84   247   160    76];\r\nassert(isequal(EMEOAEPencoding(M,L,seed,k),EM))","published":true,"deleted":false,"likes_count":1,"comments_count":12,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-09-06T23:39:52.000Z","updated_at":"2025-10-15T14:05:18.000Z","published_at":"2019-09-07T00:59:36.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEME-OAEP encoding of input message using a Feistel network with SHA-1 hashing and mask generation function (MGF1) (see problem 44963/below link, section 9.1.1.1 (figure 1 shows the encoding process)). Inputs will include message (M), label (L), a random seed (seed) array of octets of length 20 (needed such that outputs can be compared), and output length (k). Output (EM) array will be an array of octets of length, k. Hash length will always be 20 from SHA-1 (160-20 bytes). The character length of input message will never exceed k-42.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[M = 'I like to swim.';%input\\nL = 'abcdefghijklmnopqrstuvwxyz';%input\\nseed = [147,11,108,119,5,16,236,136,93,93,38,38,89,86,200,124,118,33,226,172];%input\\nk = 100;%input\\nEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\\n148,12,50,108,248,32,94];%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44956,"title":"Determine RSA keys (public and private) given two prime number character strings (p and q)","description":"Given two prime number character strings (p and q), generate the RSA public and private keys (n and d) with e = 65537. The more difficult part is doing this without the use of symbolic numbers.\r\nExample: p = '3355335697481001330501721', q = '5955344080483688912855719'\r\nn='19982178584029090861856118769095354822153154192399'\r\nd='3270348772331599380262578849367006078599068947553'\r\n\r\n\u003chttps://simple.wikipedia.org/wiki/RSA_algorithm\u003e\r\n\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eGiven two prime number character strings (p and q), generate the RSA public and private keys (n and d) with e = 65537. The more difficult part is doing this without the use of symbolic numbers.\r\nExample: p = '3355335697481001330501721', q = '5955344080483688912855719'\r\nn='19982178584029090861856118769095354822153154192399'\r\nd='3270348772331599380262578849367006078599068947553'\u003c/p\u003e\u003cp\u003e\u003ca href = \"https://simple.wikipedia.org/wiki/RSA_algorithm\"\u003ehttps://simple.wikipedia.org/wiki/RSA_algorithm\u003c/a\u003e\u003c/p\u003e","function_template":"function [n,d] = keyGeneration(p,q)\r\n  n = p;\r\n  d = q;\r\nend","test_suite":"%%\r\np = '3355335697481001330501721';\r\nq = '5955344080483688912855719';\r\nn='19982178584029090861856118769095354822153154192399';\r\nd='3270348772331599380262578849367006078599068947553';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '813610636673';\r\nq = '1605983302589';\r\nn='1306645097305643499246397';\r\nd='355984378478555057894913';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '67979691391330950855242581938207942707483223433259';\r\nq = '6153843674264879356192291854148321819411378704398479';\r\nn='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061';\r\nd='8444986024072025211908427894173383040354675378319105204646840203847580180874615752845913488969020869';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '9889977922600049892469466917642800243744956526655686322206918503863571743809023708648966023469645149';\r\nq = '2476454822450020555811121392457617785385805217059253393679351596046272567110905233495088857069108236299';\r\nn = '24492083520347129695334786995557239882540750861618765872694983337614252441655470479409598244691513160097634784088025768219041142794039842531021683737585081956313858395523050254392582005967309810771063551';\r\nd = '7043758337908398316945695794623843894382227935971901356005844728128437829322707899292187736941661046350269216062193211515498221491327821445579367736374708711769362662280124297131956999441862850977388289';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))\r\n%%\r\np = '26892754546730837119898059580995437039544399594421875855251066246511044160199048288603963625982639028058714345196159764252398791569637860905138287322706679328840515337572608690956308136959236074835599';\r\nq = '76019400184540822543696224086250845563040709795227937154720461468348727220343229834542918037619525984430713380822472295398107810565069813256377730791194881206750953165713183208458761595898204049235781';\r\nn='2044371069952561243871813747701535503388267616657953475148898181142012590397809234167373308955772082860082985954286137615597515257087506574051530104475374974920093127841789408014496870693507622812332673504654584870100580476794800708440785082437228308551107726064054828640053321250498545183042994878498928173976370185712833904492317580152665428272199317847097773542066059565512439224992672101163367819';\r\nd='131358569595346680469722564224349085322306406056832660693226883146757023027681686453130430199929142940992255578581548217026735077095312421736286269892515739496597527524021166625708322359741224036234988705082882699895245449017415856831226734459122764117157172961113990706104659539690141481103935528273973382371183154438463086325519326121228923730136467766036183357672350586091588640276470994058874793';\r\n[a,b]=keyGeneration(p,q);\r\nassert(isequal(a,n))\r\nassert(isequal(b,d))","published":true,"deleted":false,"likes_count":3,"comments_count":10,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":"2019-08-28T22:45:19.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-08-26T02:38:07.000Z","updated_at":"2026-03-04T16:55:19.000Z","published_at":"2019-08-26T02:45:23.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two prime number character strings (p and q), generate the RSA public and private keys (n and d) with e = 65537. The more difficult part is doing this without the use of symbolic numbers. Example: p = '3355335697481001330501721', q = '5955344080483688912855719' n='19982178584029090861856118769095354822153154192399' d='3270348772331599380262578849367006078599068947553'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://simple.wikipedia.org/wiki/RSA_algorithm\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://simple.wikipedia.org/wiki/RSA_algorithm\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44383,"title":"Code breaker, Part III:  Operation Xiangliu","description":"You have been tasked with decoding several batches of coded messages that have been intercepted.  \r\n\r\nBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003chttps://en.wikipedia.org/wiki/Caesar_cipher Caesar cipher\u003e (a type of \u003chttps://en.wikipedia.org/wiki/Substitution_cipher substitution cipher\u003e), an example of which is the \u003chttps://en.wikipedia.org/wiki/ROT13 ROT13 cipher\u003e (discussed in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher Cody Challenge Problem 78\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary _between_ (not within) batches — also, here you need to decode, not encode.  \r\n\r\nThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation.  A few decoding options are at your organisation's disposal:  \r\n\r\n# Test the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\r\n# Test the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g. \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44351 \"Operation Phoenix\"\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.  \r\n# Test the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\r\n\r\nThe *third option* will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.  \r\n\r\nYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \"to be\", rather than the various inflected forms such as \"am\", \"is\", \"are\") like those based on the \u003chttps://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language OEC\u003e or \u003chttps://www.wordfrequency.info/free.asp?s=y COCA\u003e, and after setting aside \u003chttp://world-english.org/english500.htm another list\u003e you finally choose the \u003chttp://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf list based on the BNC\u003e as the most reliable, and will use the first 100 words on that list.  \r\nThis list will be available for you to access as an input variable, |bncWordlist|, to your function. Note: (i) some entries on the list are morphemes (e.g. \"\u0026#x200A;n't\u0026#x200A;\" and \"\u0026#x200A;'s\u0026#x200A;\") rather than words;  (ii) some entries appear more than once (representing different grammatical word classes).  Of course, in the original messages any capitalisation might be used.  \r\n\r\nYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in |bncWordlist|.  Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude;  matching three-twentieths would be 50% certitude, and so on.  Certitude shall be reported as a percentage, rounded _up_ to the nearest integer, not greater than 100.  You need to maximise your certitude for each batch by appropriate choice of the shifting parameter.   If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\r\n\r\nYour task is to crack the codes and report back in a \u003chttp://au.mathworks.com/help/matlab/ref/struct.html structure array\u003e: \u0026nbsp; (1) the shifting parameter that had been used in the encoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e] (usually scalar, but may be column vector); \u0026nbsp; (2) the decoded messages [as a \u003chttp://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta cell array\u003e (containing \u003chttp://au.mathworks.com/help/matlab/ref/char.html character arrays\u003e)] (usually an array with a single row, but occasionally with multiple rows); \u0026nbsp; (3) your 'certitude' in the decoding [as \u003chttp://au.mathworks.com/help/matlab/ref/uint8.html uint8\u003e] (always scalar).  \r\nThe name of the structure array shall be |s|, with respective fields |shift|, |message|, and |certitude|.  \r\n\r\n*EXAMPLE 1*\r\n\r\nSuppose the batch contained two encoded messages — _\"Vomftt qvstvfe, pqfo op eppst.\"_ and _\"Ffmt dbo ljmm, opu pomz xpvoe.\"_ (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  \r\nThus the original messages would have been:  _\"Unless pursued, open no doors.\"_ and _\"Eels can kill, not only wound.\"_ .  Twelve of the 51 characters have been matched:  \"no\", \"can\", \"not\", and \"only\".  \r\n\r\nThe correct answer would therefore comprise:  \r\n\r\n  s.shift = uint8(1)  \r\n  s.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\r\n  s.certitude = uint8(79)\r\n\r\n*EXAMPLE 2*\r\n\r\nSuppose the batch contained one encoded message — _\"Oa oqvvq'u cnycau dggp: \"Ctu itcvkc ctvku\".\"_ (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied.  In that case A→C, B→D, ..., Y→A, and Z→B;  similarly, a→c, b→d, ..., y→a, and z→b.  \r\nThus the original message would have been:  _\"My motto's always been: \"Ars gratia artis\".\"_ .  Eight of the 37 characters have been matched: \"My\", \"\u0026#x200A;'s\u0026#x200A;\", and \"been\".  Note carefully that:  \"\u0026#x200A;'s\u0026#x200A;\" should only be matched once;  \"to\" (in motto), \"be\" (in been), \"at\" (in gratia), \"is\" (in artis) and \"a\" (passim) should _not_ be matched at all;  and \"\u0026#x200A;'\u0026#x200A;\" will only ever be used as an apostrophe (never as a quotation mark).  \r\n\r\nThe correct answer would therefore comprise:  \r\n\r\n  s.shift = uint8(2)  \r\n  s.message = {'My motto''s always been: \"Ars gratia artis\".'}\r\n  s.certitude = uint8(73)\r\n\r\nIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.  \r\n\r\n|Note:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)|  \r\n\r\nTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".  \r\n\r\n----------\r\n\r\nPrevious problem:  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44356 Operation Orthos\u003e.  Next problem:  TBA.","description_html":"\u003cp\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/p\u003e\u003cp\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple \u003ca href = \"https://en.wikipedia.org/wiki/Caesar_cipher\"\u003eCaesar cipher\u003c/a\u003e (a type of \u003ca href = \"https://en.wikipedia.org/wiki/Substitution_cipher\"\u003esubstitution cipher\u003c/a\u003e), an example of which is the \u003ca href = \"https://en.wikipedia.org/wiki/ROT13\"\u003eROT13 cipher\u003c/a\u003e (discussed in \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\"\u003eCody Challenge Problem 78\u003c/a\u003e).  As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged.  Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary \u003ci\u003ebetween\u003c/i\u003e (not within) batches — also, here you need to decode, not encode.\u003c/p\u003e\u003cp\u003eThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation.  A few decoding options are at your organisation's disposal:\u003c/p\u003e\u003col\u003e\u003cli\u003eTest the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\u003c/li\u003e\u003cli\u003eTest the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g. \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44351\"\u003e\"Operation Phoenix\"\u003c/a\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.\u003c/li\u003e\u003cli\u003eTest the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eThe \u003cb\u003ethird option\u003c/b\u003e will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.\u003c/p\u003e\u003cp\u003eYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \"to be\", rather than the various inflected forms such as \"am\", \"is\", \"are\") like those based on the \u003ca href = \"https://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language\"\u003eOEC\u003c/a\u003e or \u003ca href = \"https://www.wordfrequency.info/free.asp?s=y\"\u003eCOCA\u003c/a\u003e, and after setting aside \u003ca href = \"http://world-english.org/english500.htm\"\u003eanother list\u003c/a\u003e you finally choose the \u003ca href = \"http://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf\"\u003elist based on the BNC\u003c/a\u003e as the most reliable, and will use the first 100 words on that list.  \r\nThis list will be available for you to access as an input variable, \u003ctt\u003ebncWordlist\u003c/tt\u003e, to your function. Note: (i) some entries on the list are morphemes (e.g. \"\u0026#x200A;n't\u0026#x200A;\" and \"\u0026#x200A;'s\u0026#x200A;\") rather than words;  (ii) some entries appear more than once (representing different grammatical word classes).  Of course, in the original messages any capitalisation might be used.\u003c/p\u003e\u003cp\u003eYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in \u003ctt\u003ebncWordlist\u003c/tt\u003e.  Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude;  matching three-twentieths would be 50% certitude, and so on.  Certitude shall be reported as a percentage, rounded \u003ci\u003eup\u003c/i\u003e to the nearest integer, not greater than 100.  You need to maximise your certitude for each batch by appropriate choice of the shifting parameter.   If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\u003c/p\u003e\u003cp\u003eYour task is to crack the codes and report back in a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/struct.html\"\u003estructure array\u003c/a\u003e: \u0026nbsp; (1) the shifting parameter that had been used in the encoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e] (usually scalar, but may be column vector); \u0026nbsp; (2) the decoded messages [as a \u003ca href = \"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\"\u003ecell array\u003c/a\u003e (containing \u003ca href = \"http://au.mathworks.com/help/matlab/ref/char.html\"\u003echaracter arrays\u003c/a\u003e)] (usually an array with a single row, but occasionally with multiple rows); \u0026nbsp; (3) your 'certitude' in the decoding [as \u003ca href = \"http://au.mathworks.com/help/matlab/ref/uint8.html\"\u003euint8\u003c/a\u003e] (always scalar).  \r\nThe name of the structure array shall be \u003ctt\u003es\u003c/tt\u003e, with respective fields \u003ctt\u003eshift\u003c/tt\u003e, \u003ctt\u003emessage\u003c/tt\u003e, and \u003ctt\u003ecertitude\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003e\u003cb\u003eEXAMPLE 1\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSuppose the batch contained two encoded messages — \u003ci\u003e\"Vomftt qvstvfe, pqfo op eppst.\"\u003c/i\u003e and \u003ci\u003e\"Ffmt dbo ljmm, opu pomz xpvoe.\"\u003c/i\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied.  In that case A→B, B→C, ..., Y→Z, and Z→A;  similarly, a→b, b→c, ..., y→z, and z→a.  \r\nThus the original messages would have been:  \u003ci\u003e\"Unless pursued, open no doors.\"\u003c/i\u003e and \u003ci\u003e\"Eels can kill, not only wound.\"\u003c/i\u003e .  Twelve of the 51 characters have been matched:  \"no\", \"can\", \"not\", and \"only\".\u003c/p\u003e\u003cp\u003eThe correct answer would therefore comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(1)  \r\ns.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\r\ns.certitude = uint8(79)\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eEXAMPLE 2\u003c/b\u003e\u003c/p\u003e\u003cp\u003eSuppose the batch contained one encoded message — \u003ci\u003e\"Oa oqvvq'u cnycau dggp: \"Ctu itcvkc ctvku\".\"\u003c/i\u003e (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied.  In that case A→C, B→D, ..., Y→A, and Z→B;  similarly, a→c, b→d, ..., y→a, and z→b.  \r\nThus the original message would have been:  \u003ci\u003e\"My motto's always been: \"Ars gratia artis\".\"\u003c/i\u003e .  Eight of the 37 characters have been matched: \"My\", \"\u0026#x200A;'s\u0026#x200A;\", and \"been\".  Note carefully that:  \"\u0026#x200A;'s\u0026#x200A;\" should only be matched once;  \"to\" (in motto), \"be\" (in been), \"at\" (in gratia), \"is\" (in artis) and \"a\" (passim) should \u003ci\u003enot\u003c/i\u003e be matched at all;  and \"\u0026#x200A;'\u0026#x200A;\" will only ever be used as an apostrophe (never as a quotation mark).\u003c/p\u003e\u003cp\u003eThe correct answer would therefore comprise:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es.shift = uint8(2)  \r\ns.message = {'My motto''s always been: \"Ars gratia artis\".'}\r\ns.certitude = uint8(73)\r\n\u003c/pre\u003e\u003cp\u003eIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.\u003c/p\u003e\u003cp\u003e\u003ctt\u003eNote:  Many Cody solutions are hard to read and not necessarily computationally efficient.  To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable).  Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/tt\u003e\u003c/p\u003e\u003cp\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \"too slow\".\u003c/p\u003e\u003cp\u003e----------\u003c/p\u003e\u003cp\u003ePrevious problem:  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44356\"\u003eOperation Orthos\u003c/a\u003e.  Next problem:  TBA.\u003c/p\u003e","function_template":"% Comments are nice, aren't they....\r\nfunction s = decode(x, bncWordlist)\r\nend","test_suite":"%% NOTE:  \r\n% This test suite can be updated if inappropriate 'hacks' \r\n% are discovered in any submitted solutions.\r\n% The assessment of your submission may therefore change over time.  \r\n\r\nglobal bncWordlist\r\nbncWordlist = {'the', 'of', 'and', 'a', 'in', 'to', 'it', 'is', 'to', 'was', ...\r\n    'I', 'for', 'that', 'you', 'he', 'be', 'with', 'on', 'by', 'at', ...\r\n    'have', 'are', 'not', 'this', '''s', 'but', 'had', 'they', 'his', ...\r\n    'from', 'she', 'that', 'which', 'or', 'we', '''s', 'an', 'n''t', 'were', ...\r\n    'as', 'do', 'been', 'their', 'has', 'would', 'there', 'what', 'will', 'all', ...\r\n    'if', 'can', 'her', 'said', 'who', 'one', 'so', 'up', 'as', 'them', 'some', ...\r\n    'when', 'could', 'him', 'into', 'its', 'then', 'two', 'out', 'time', ...\r\n    'my', 'about', 'did', 'your', 'now', 'me', 'no', 'other', 'only', 'just', ...\r\n    'more', 'these', 'also', 'people', 'know', 'any', 'first', 'see', 'very', 'new', ...\r\n    'may', 'well', 'should', 'her', 'like', 'than', 'how', 'get', 'way', 'one', 'our'};\r\n\r\n\r\n%% Anti-hacking\r\n% EDIT (2019-07-02). Anti-hacking provision\r\n% Ensure only builtin functions will be called.\r\n! rm -v fileread.m\r\n! rm -v assert.m\r\n% END EDIT (2019-07-02)\r\n% EDIT (2018-06-18).  Anti-hacking provision\r\nRE = regexp(fileread('decode.m'), '\\w+', 'match');\r\ntabooWords = {'ans', 'assert', 'freepass', 'tic'};\r\ntestResult = cellfun( @(z) ismember(z, tabooWords), RE );\r\nmsg = ['Please do not do that in your code!' char([10 13]) ...\r\n    'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ...\r\n    'Banned word.' char([10 13])];\r\nassert(~any(  cellfun( @(z) ismember(z, tabooWords), RE )  ), msg)\r\n\r\nfor j = 1 : randi(10)\r\n    decode({'Pizza for dinner.'}, {'mozzarella', 'mushrooms'});\r\nend;\r\n% END EDIT (2018-06-18)\r\n\r\n\r\n%% Test 1\r\nglobal bncWordlist\r\nx =                 {'Vomftt qvstvfe, pqfo op eppst.', 'Ffmt dbo ljmm, opu pomz xpvoe.'};\r\ns_correct.shift = uint8(1);\r\ns_correct.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'};\r\ns_correct.certitude = uint8(79);\r\ns = decode(x, bncWordlist);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.' )\r\nassert( isequal(s.message{1}, s_correct.message{1}), 'Wrong message{1}.' )\r\nassert( isequal(s.message{2}, s_correct.message{2}), 'Wrong message{2}.' )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.' )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.' )\r\nassert( isequal(s, s_correct), 'Wrong s.' )\r\nassert( isequal(class(s.shift), 'uint8'), 'Wrong class.' )\r\nassert( isequal(class(s.message), 'cell'), 'Wrong class.'  )\r\nassert( isequal(class(s.message{1}), 'char'), 'Wrong class.'  )\r\nassert( isequal(class(s.certitude), 'uint8'), 'Wrong class.'  )\r\n\r\n\r\n%% Test 2\r\nglobal bncWordlist\r\nx =                 {'Doo zduiduh lv edvhg rq ghfhswlrq.', ...\r\n    'Khqfh, zkhq deoh wr dwwdfn, zh pxvw vhhp xqdeoh;  zkhq xvlqj rxu irufhv, zh pxvw vhhp lqdfwlyh;  zkhq zh duh qhdu, zh pxvw pdnh wkh hqhpb eholhyh zh duh idu dzdb; zkhq idu dzdb, zh pxvw pdnh klp eholhyh zh duh qhdu.'};\r\ns_correct.shift = uint8(3);\r\ns_correct.message = {'All warfare is based on deception.', ...\r\n    'Hence, when able to attack, we must seem unable;  when using our forces, we must seem inactive;  when we are near, we must make the enemy believe we are far away; when far away, we must make him believe we are near.'};\r\ns_correct.certitude = uint8(95);\r\ns = decode(x, bncWordlist);\r\n%disp(' *** ');  disp(s.message);  disp(' *** ')\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 3\r\nglobal bncWordlist\r\nx =                 {'Elia lrq yxfqp ql bkqfzb qeb bkbjv.  Cbfdk afploabo, xka zorpe efj.', ...\r\n    'Fc eb fp pbzrob xq xii mlfkqp, yb mobmxoba clo efj.  Fc eb fp fk prmboflo pqobkdqe, bsxab efj.'};\r\ns_correct.shift = uint8(23);\r\ns_correct.message = {'Hold out baits to entice the enemy.  Feign disorder, and crush him.', ...\r\n    'If he is secure at all points, be prepared for him.  If he is in superior strength, evade him.'};\r\ns_correct.certitude = uint8(100);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 4\r\nglobal bncWordlist\r\nx =                 {'Ax qgmj ghhgfwfl ak gx uzgdwjau lwehwj, kwwc lg ajjalslw zae.  Hjwlwfv lg tw owsc, lzsl zw esq yjgo sjjgysfl.', ...\r\n    'Ax zw ak lscafy zak wskw, yanw zae fg jwkl.', ...\r\n    'Ax zak xgjuwk sjw mfalwv, kwhsjslw lzwe.', ...\r\n    'Sllsuc zae ozwjw zw ak mfhjwhsjwv, shhwsj ozwjw qgm sjw fgl wphwulwv.'};\r\ns_correct.shift = uint8(18);\r\ns_correct.message = {'If your opponent is of choleric temper, seek to irritate him.  Pretend to be weak, that he may grow arrogant.', ...\r\n    'If he is taking his ease, give him no rest.', ...\r\n    'If his forces are united, separate them.', ...\r\n    'Attack him where he is unprepared, appear where you are not expected.'};\r\ns_correct.certitude = uint8(100);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 5\r\nglobal bncWordlist\r\nx =                 {'Aes cèwo vo foxd bémyvdo vo dowzy', ...\r\n    'Yx wo dbksdo no dbkîdbo aekxn to dbksdo no vk népksdo ne csvoxmo / Vo csvoxmo ocd n''yb, wksc t''ks mryscs vk mknoxmo', ... \r\n    'Mrkaeo wyd, mrkaeo zrbkco nsdc kfom owzrkco / Pksd no Mvkeno WM, vo mywwkxny no vk zrbkco', ...\r\n    'Mkb t''cesc ex WM n''kddkaeo, ckxc dsmc, kedroxdsaeo zkc ox dym / Zbêd à pbkzzob ceb vo lokd zyeb vo wyefowoxd rsz-ryz', ...\r\n    'Ne bkz n''kddkaeo aes pbkzzo, ézkdo, wkdbkaeo od zkdkdbkaeo / Zvec no ckxq de mvkaeoc, t''cesc WM noc Mkbzkdoc', ...\r\n    'Vo zénkqyqeo ox fyqeo ke xyw no myno Cyvkkb ye Mvkeno WM / Do zbyzyco n''émyedob moms / Ae''yx ézovvo voc fyiovvoc, nèc ae''yx cyxxo voc myxcyxxoc'};\r\ns_correct.shift = uint8([0 21]');\r\n% TIP:  The original message was not English!\r\ns_correct.message(1, :) = {'Aes cèwo vo foxd bémyvdo vo dowzy', ... \r\n    'Yx wo dbksdo no dbkîdbo aekxn to dbksdo no vk népksdo ne csvoxmo / Vo csvoxmo ocd n''yb, wksc t''ks mryscs vk mknoxmo', ... \r\n    'Mrkaeo wyd, mrkaeo zrbkco nsdc kfom owzrkco / Pksd no Mvkeno WM, vo mywwkxny no vk zrbkco', ... \r\n    'Mkb t''cesc ex WM n''kddkaeo, ckxc dsmc, kedroxdsaeo zkc ox dym / Zbêd à pbkzzob ceb vo lokd zyeb vo wyefowoxd rsz-ryz', ... \r\n    'Ne bkz n''kddkaeo aes pbkzzo, ézkdo, wkdbkaeo od zkdkdbkaeo / Zvec no ckxq de mvkaeoc, t''cesc WM noc Mkbzkdoc', ... \r\n    'Vo zénkqyqeo ox fyqeo ke xyw no myno Cyvkkb ye Mvkeno WM / Do zbyzyco n''émyedob moms / Ae''yx ézovvo voc fyiovvoc, nèc ae''yx cyxxo voc myxcyxxoc'}\r\ns_correct.message(2, :) = {'Fjx hèbt at ktci gérdait at itbed', ... \r\n    'Dc bt igpxit st igpîigt fjpcs yt igpxit st ap séupxit sj hxatcrt / At hxatcrt thi s''dg, bpxh y''px rwdxhx ap rpstcrt', ... \r\n    'Rwpfjt bdi, rwpfjt ewgpht sxih pktr tbewpht / Upxi st Rapjst BR, at rdbbpcsd st ap ewgpht', ... \r\n    'Rpg y''hjxh jc BR s''piipfjt, hpch ixrh, pjiwtcixfjt eph tc idr / Egêi à ugpeetg hjg at qtpi edjg at bdjktbtci wxe-wde', ... \r\n    'Sj gpe s''piipfjt fjx ugpeet, éepit, bpigpfjt ti epipigpfjt / Eajh st hpcv ij rapfjth, y''hjxh BR sth Rpgepith', ... \r\n    'At eéspvdvjt tc kdvjt pj cdb st rdst Hdappg dj Rapjst BR / It egdedht s''érdjitg rtrx / Fj''dc éetaat ath kdntaath, sèh fj''dc hdcct ath rdchdccth'}\r\ns_correct.certitude = uint8(11);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 6\r\nglobal bncWordlist\r\nx =                 {'Brvdujcnm mrbxamna yxbcdujcnb ynaonlc mrblryurwn;  brvdujcnm onja yxbcdujcnb lxdajpn;  brvdujcnm fnjtwnbb yxbcdujcnb bcanwpcq.' ...\r\n    'X mrerwn jac xo bdkcunch jwm bnlanlh!'};\r\ns_correct.shift = uint8(9);\r\ns_correct.message = {'Simulated disorder postulates perfect discipline;  simulated fear postulates courage;  simulated weakness postulates strength.' ...\r\n    'O divine art of subtlety and secrecy!'};\r\ns_correct.certitude = uint8(12);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 7\r\nglobal bncWordlist\r\nx =                 {'Nv treefk vekvi zekf rcczretv nzky evzxysfizex gizetvj lekzc nv riv rthlrzekvu nzky kyvzi uvjzxej.', ... \r\n    'Nv riv efk wzk kf cvru re ridp fe kyv drity lecvjj nv riv wrdzczri nzky kyv wrtv fw kyv tflekip — zkj dflekrzej reu wfivjkj, zkj gzkwrccj reu givtzgztvj, zkj drijyvj reu jnrdgj.', ... \r\n    'Nv jyrcc sv lerscv kf klie erklirc rumrekrxvj kf rttflek lecvjj nv drbv ljv fw cftrc xlzuvj.'};\r\ns_correct.shift = uint8(17);\r\ns_correct.message = {'We cannot enter into alliance with neighboring princes until we are acquainted with their designs.', ...  \r\n    'We are not fit to lead an army on the march unless we are familiar with the face of the country — its mountains and forests, its pitfalls and precipices, its marshes and swamps.', ...  \r\n    'We shall be unable to turn natural advantages to account unless we make use of local guides.'};\r\ns_correct.certitude = uint8(97);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 8\r\nglobal bncWordlist\r\nx =                 {'Oa oqvvq''u cnycau dggp: \"Ctu itcvkc ctvku\".'};\r\ns_correct.shift = uint8(2);\r\ns_correct.message = {'My motto''s always been: \"Ars gratia artis\".'};\r\ns_correct.certitude = uint8(73);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% Test 9\r\nglobal bncWordlist\r\nx =                 {'Bestow rewards without regard 2 rule;  issue orders without regard 2 previous arrangements', ...\r\n    '\"Let advance bee richly rewarded \u0026 retreat bee heavily punished.\"', ...\r\n    ' Qwertyuiop''asdfghjkl.   Zxcvbnm-0123456789 = pass. ', ...\r\n    'αβγδ — persimon–apricot hybrid.', ...\r\n    'aIanasatbebydoheifinisitmemynoofonor''ssotoupweallandanyarebutcandidforgethadhasherhimhishowitsmaynewnotnown''toneouroutseeshethetwowaswaywhoyoualsobeenfromhaveintojustknowlikemoreonlysaidsomethanthatthemthentheythistimeverywellwerewhatwhenwillwithyouraboutcouldfirstothertheirtherethesewhichwouldpeopleshould'};\r\ns_correct.shift = uint8(0);\r\ns_correct.message = x;\r\ns_correct.certitude = uint8(0);\r\ns = decode(x, bncWordlist);\r\nassert( isequal(s.shift, s_correct.shift), 'Wrong shift.'  )\r\nassert( isequal(s.message, s_correct.message), 'Wrong message.'  )\r\nassert( isequal(s.certitude, s_correct.certitude), 'Wrong certitude.'  )\r\n\r\n\r\n%% TIMING \r\n% Note:  The Time Trial section does not check accuracy; that is done above.\r\n\r\n% Acknowledgements  \r\n% Portions of this timing test code were inspired by:\r\n% (1) Problem 937. \"Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)\" by Richard Zapor.\r\n% (2) Problem 2733. \"Evil Number\" by Jan Orwat.\r\n% (3) Feedback in comments from Peng Liu.\r\n% (4) Problem Problem 1237. \"It's race time! Write a faster function than the test suite call of unique().\" by Jeremy.\r\n\r\n% INITIALISE\r\nglobal bncWordlist\r\nx =                 {'Vomftt qvstvfe, pqfo op eppst.', 'Ffmt dbo ljmm, opu pomz xpvoe.'};\r\nqSmall = 50;\r\nqBig = 1000;\r\n%cutoffTimeBig = 10;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\n\r\n% EDIT (2018-06-17).  Reduced time [slightly] to pose reasonable challenge.\r\n% Accounted for improving Cody server speed per Problem 44655.\r\ncutoffTimeBig = 8;    % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.\r\ntRef = datetime('2018-06-17', 'InputFormat','yyyy-MM-dd');\r\ntNow = datetime('now');\r\nyearsElapsed = (datenum(tNow) - datenum(tRef)) / 365.24;\r\ndisp(' . ');\r\nfprintf('\\r\\n\\r\\n\\r\\nSubmission evaluated for speed on %s.\\r\\n', datestr(tNow, 'dd mmmm yyyy'))\r\nrInf = 0.2;   delta = cutoffTimeBig - rInf;  tau = 3.6;  % Data from Problem 44655, based on Problem 963.\r\nqBig = ceil( qBig * (cutoffTimeBig - rInf) * exp(yearsElapsed/tau) / delta );\r\nfprintf('\\r\\n\\r\\n\\r\\nTo account for computational power increases over time, number of iterations increased to %u.\\r\\n', qBig)\r\n% END EDIT (2018-06-17)\r\n\r\n\r\n% *** PRELIMINARY TIMING WITH timeit ***\r\nfDecode = @()   decode(x, bncWordlist);\r\ndt_timeit = timeit( fDecode );\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\nfprintf('APPROXIMATE time to decode %u message batches ~ %2.2f seconds, according to ''timeit''.\\n\\r', qBig, dt_timeit * qBig)\r\n\r\n% *** PRELIMINARY TIMING WITH SHORT LOOP ***\r\n% In case the submitted function has a lot of text output, \r\n% get an estimate based on just a few iterations\r\n% Initialise\r\nt0 = clock;\r\n\r\n% Loop\r\nfor i = 1 : qSmall\r\n    solution = decode(x, bncWordlist);\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\n%fprintf('Your wall time to decode %u message batches = %i seconds.\\n\\r', qSmall, floor(dt))\r\nfprintf('APPROXIMATE wall time to decode %u message batches ~ %2.2f seconds, by extrapolating from %u batches.\\n\\r', qBig, dt * qBig / qSmall, qSmall)\r\n\r\n% *** 'OFFICIAL' TIMING ***\r\n% Re-initialise timer\r\nt0 = clock;\r\nt0_cpu = cputime;\r\n\r\n% Loop\r\nfor i = 1 : qBig\r\n    % EDIT (2018-06-17).   Ensure each case is unique.\r\n    characters = ['  ,   .' char(randi([97,122], [1,23]))];\r\n    x{2} = characters( randperm(30) );\r\n    % END EDIT (2018-06-17)\r\n    solution = decode(x, bncWordlist);\r\nend;\r\n\r\n% Compute and display elapsed time.\r\ndt = etime(clock, t0);\r\nfor dummy = 1 : 10,  disp(' . ');  end;\r\nfprintf('Your wall time to decode %u message batches = %2.2f seconds.\\n\\r', qBig, dt)\r\n\r\ndt_cpu = (cputime - t0_cpu);\r\nfprintf(' ( Your CPU time for this = %2.2f seconds. ) \\n\\r', dt_cpu)\r\n\r\n% Display (default) Cody size-based score.\r\nall_nodes = mtree('decode.m', '-file');\r\nsize_score = count(all_nodes);\r\nfprintf('Your Cody-standard size-based score = %i.\\n\\r', size_score)\r\n\r\n% Report revised performance score\r\ncombinedScore = size_score + round(dt * 10);\r\nfprintf('Your combined score = %i.\\n\\r', combinedScore)\r\ndisp('     -----=====|||||=====-----     ')\r\n\r\n% Now disallow any candidate solutions that are TOO SLOW!\r\nif dt \u003e cutoffTimeBig, \r\n    fprintf('Sorry, your submission is TOO SLOW.  It must be able to finish within %u seconds.\\n\\r', cutoffTimeBig)\r\nend;\r\n\r\nassert( dt \u003c= cutoffTimeBig, 'Exceeded time limit specified in Test Suite.' )","published":true,"deleted":false,"likes_count":2,"comments_count":16,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":"2019-07-02T13:23:18.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2017-10-12T23:17:24.000Z","updated_at":"2026-04-02T20:05:58.000Z","published_at":"2017-10-15T06:52:40.000Z","restored_at":"2017-10-25T07:03:11.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been tasked with decoding several batches of coded messages that have been intercepted.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased on previous intelligence that has been gathered, you can be confident that the messages were all encoded using a simple\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Caesar_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCaesar cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (a type of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Substitution_cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003esubstitution cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e), an example of which is the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/ROT13\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eROT13 cipher\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (discussed in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/78-implement-a-rot13-cipher\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Challenge Problem 78\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e). As in the Cody Challenge Problem, uppercase and lowercase letters are handled independently of one another, and all other characters (e.g. punctuation, numbers, accented letters) are unchanged. Unlike the Cody Challenge Problem, here the number of letters to shift is not known in advance, and will vary\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebetween\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (not within) batches — also, here you need to decode, not encode.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThese latest activities that you are investigating have been nicknamed 'Operation Xiangliu' by your own organisation. A few decoding options are at your organisation's disposal:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings against all words in a large dictionary — this could work, but it is very slow.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings for the appearance of a name or phrase that is certain to appear regularly (e.g.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44351\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"Operation Phoenix\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) — unfortunately as yet there is not enough knowledge of the activities to be sure of a suitable name or phrase to use.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTest the candidate decodings against all words in a short list comprising, say, the hundred most frequently used English words.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethird option\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will be faster than the first option, and more reliable than the second option, so this is the approach you will be taking.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been careful to avoid using 'lemmatised' lists (which contain e.g. the verb \\\"to be\\\", rather than the various inflected forms such as \\\"am\\\", \\\"is\\\", \\\"are\\\") like those based on the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://web.archive.org/web/20111226085859/http://oxforddictionaries.com/words/the-oec-facts-about-the-language\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOEC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.wordfrequency.info/free.asp?s=y\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCOCA\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, and after setting aside\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://world-english.org/english500.htm\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eanother list\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e you finally choose the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://ucrel.lancs.ac.uk/bncfreq/samples/120.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003elist based on the BNC\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e as the most reliable, and will use the first 100 words on that list. This list will be available for you to access as an input variable,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebncWordlist\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, to your function. Note: (i) some entries on the list are morphemes (e.g. \\\" n't \\\" and \\\" 's \\\") rather than words; (ii) some entries appear more than once (representing different grammatical word classes). Of course, in the original messages any capitalisation might be used.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have been instructed that your 'certitude' (degree of confidence) in the decoding must be reported for each batch, and shall depend proportionally upon the sum of the characters for the words/morphemes in the decoded message that match words/morphemes in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebncWordlist\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Being able to match words/morphemes accounting for three-tenths of the characters (excluding spaces) shall correspond to 100% certitude; matching three-twentieths would be 50% certitude, and so on. Certitude shall be reported as a percentage, rounded\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eup\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to the nearest integer, not greater than 100. You need to maximise your certitude for each batch by appropriate choice of the shifting parameter. If there are multiple shifts of equal certitude, report both options on different rows (arranged in order of ascending shift parameter).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to crack the codes and report back in a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/struct.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estructure array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e: (1) the shifting parameter that had been used in the encoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e] (usually scalar, but may be column vector); (2) the decoded messages [as a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/cell.html?s_tid=doc_ta\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ecell array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (containing\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/char.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003echaracter arrays\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e)] (usually an array with a single row, but occasionally with multiple rows); (3) your 'certitude' in the decoding [as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://au.mathworks.com/help/matlab/ref/uint8.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003euint8\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e] (always scalar). The name of the structure array shall be\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, with respective fields\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eshift\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emessage\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecertitude\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEXAMPLE 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained two encoded messages —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Vomftt qvstvfe, pqfo op eppst.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Ffmt dbo ljmm, opu pomz xpvoe.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as character arrays within a cell array) — and a (right-shifting) ROT1 cipher had been applied. In that case A→B, B→C, ..., Y→Z, and Z→A; similarly, a→b, b→c, ..., y→z, and z→a. Thus the original messages would have been: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Unless pursued, open no doors.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Eels can kill, not only wound.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . Twelve of the 51 characters have been matched: \\\"no\\\", \\\"can\\\", \\\"not\\\", and \\\"only\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would therefore comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(1)  \\ns.message = {'Unless pursued, open no doors.', 'Eels can kill, not only wound.'}\\ns.certitude = uint8(79)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEXAMPLE 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the batch contained one encoded message —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"Oa oqvvq'u cnycau dggp: \\\"Ctu itcvkc ctvku\\\".\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (provided as a character array within a cell array) — and a (right-shifting) ROT2 cipher had been applied. In that case A→C, B→D, ..., Y→A, and Z→B; similarly, a→c, b→d, ..., y→a, and z→b. Thus the original message would have been: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"My motto's always been: \\\"Ars gratia artis\\\".\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . Eight of the 37 characters have been matched: \\\"My\\\", \\\" 's \\\", and \\\"been\\\". Note carefully that: \\\" 's \\\" should only be matched once; \\\"to\\\" (in motto), \\\"be\\\" (in been), \\\"at\\\" (in gratia), \\\"is\\\" (in artis) and \\\"a\\\" (passim) should\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e be matched at all; and \\\" ' \\\" will only ever be used as an apostrophe (never as a quotation mark).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe correct answer would therefore comprise:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[s.shift = uint8(2)  \\ns.message = {'My motto''s always been: \\\"Ars gratia artis\\\".'}\\ns.certitude = uint8(73)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the batch of messages cannot be decoded when following the above assumptions, then return the original encoded message(s) unchanged, with a shift of zero and a certitude of zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNote: Many Cody solutions are hard to read and not necessarily computationally efficient. To direct attention toward efficient runtime speed of execution, timings are measured in the Test Suite, and reported back (if the submission is runnable). Although the timings are not perfectly reproducible, they do provide an indication of computational resource demand. (Try resubmitting on another day if your code runs slowly, in case it is caused by a server issue.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo provide some extra motivation for you to get your code to run efficiently, it will fail the Test Suite if it is deemed \\\"too slow\\\".\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e----------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious problem: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44356\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eOperation Orthos\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: TBA.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45212,"title":"AES MixColumns() Transformation","description":"Given a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm MixColumns() transformation and output a 16x2 character hexadecimal array.\r\n\r\nRefer to this link: \u003chttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003e\r\n\r\nFor example:\r\n\r\n  stateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\n  stateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];","description_html":"\u003cp\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm MixColumns() transformation and output a 16x2 character hexadecimal array.\u003c/p\u003e\u003cp\u003eRefer to this link: \u003ca href = \"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\"\u003ehttps://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/a\u003e\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003estateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];\r\n\u003c/pre\u003e","function_template":"function stateO = MixColumns(stateI)\r\n  stateO = stateI;\r\nend","test_suite":"%%\r\nstateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\r\nstateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['11';'07';'d8';'19';'d0';'5d';'b2';'07';'59';'bf';'5c';'c4';'11';'bf';'6f';'a2']; \r\nstateO=['ea'\r\n    '75'\r\n    '96'\r\n    'de'\r\n    'e9'\r\n    'a0'\r\n    'fb'\r\n    '8a'\r\n    'f0'\r\n    '1c'\r\n    '09'\r\n    '9b'\r\n    '35'\r\n    '67'\r\n    '8d'\r\n    'bc'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['82';'c5';'61';'d4';'70';'4c';'37';'c5';'cb';'08';'4a';'1c';'82';'08';'a8';'3a']; \r\nstateO=['fe'\r\n    '64'\r\n    'e2'\r\n    '8a'\r\n    'c6'\r\n    '74'\r\n    '06'\r\n    '7a'\r\n    'c3'\r\n    '19'\r\n    '73'\r\n    '3c'\r\n    '95'\r\n    '4b'\r\n    '8f'\r\n    '49'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['13';'a6';'ef';'48';'51';'29';'9a';'a6';'1f';'30';'d6';'9c';'13';'30';'c2';'80']; \r\nstateO=['70'\r\n    '26'\r\n    'a8'\r\n    'ec'\r\n    'e5'\r\n    '10'\r\n    'a6'\r\n    '17'\r\n    '24'\r\n    '82'\r\n    '27'\r\n    'e4'\r\n    '34'\r\n    'ae'\r\n    '27'\r\n    'dc'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['70'\r\n    '26'\r\n    'a8'\r\n    'ec'\r\n    'e5'\r\n    '10'\r\n    'a6'\r\n    '17'\r\n    '24'\r\n    '82'\r\n    '27'\r\n    'e4'\r\n    '34'\r\n    'ae'\r\n    '27'\r\n    'dc'];\r\nstateO=['ce'\r\n    '33'\r\n    '32'\r\n    'dd'\r\n    '50'\r\n    '23'\r\n    '9b'\r\n    'ac'\r\n    '16'\r\n    'b6'\r\n    'df'\r\n    '1a'\r\n    '7a'\r\n    'c6'\r\n    'ab'\r\n    '76'];\r\nassert(isequal(MixColumns(stateI),stateO))\r\n%%\r\nstateI=['ce'\r\n    '33'\r\n    '32'\r\n    'dd'\r\n    '50'\r\n    '23'\r\n    '9b'\r\n    'ac'\r\n    '16'\r\n    'b6'\r\n    'df'\r\n    '1a'\r\n    '7a'\r\n    'c6'\r\n    'ab'\r\n    '76'];\r\nstateO=['3d'\r\n    '23'\r\n    'e5'\r\n    'e9'\r\n    'f2'\r\n    '0c'\r\n    'b1'\r\n    '0b'\r\n    '28'\r\n    '01'\r\n    '2b'\r\n    '67'\r\n    '78'\r\n    '7d'\r\n    '6b'\r\n    '0f'];\r\nassert(isequal(MixColumns(stateI),stateO))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-11-21T18:10:13.000Z","updated_at":"2025-10-11T16:05:08.000Z","published_at":"2019-11-21T18:19:12.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a 16x2 input character hexadecimal array representing the AES state, execute the AES algorithm MixColumns() transformation and output a 16x2 character hexadecimal array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRefer to this link:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://csrc.nist.gov/csrc/media/publications/fips/197/final/documents/fips-197.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[stateI=['e3';'38';'2d';'8e';'60';'8d';'3e';'38';'15';'f4';'a7';'88';'e3';'f4';'06';'1a'];\\nstateO=['36';'6a';'08';'2c';'4a';'1b';'d9';'63';'02';'9c';'37';'67';'c6';'00';'35';'f8'];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44924,"title":"Create State Array for initiating SHA-3-224 Hash","description":"Create binary represented state array (as the initial input to the sponge function (f)) from any length character array (N) with width (b=1600), digest length (d=224) and lane size (w=64) using SHA-3 Standard:\r\n\r\n\u003c\u003chttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf\u003e\u003e. \r\n\r\nConvert character array to binary representation using UTF-8 value of each character. Output state array will be a matrix with size (5,5,64). Padding in accordance with the standard is required. XOR of the rate bits (r) with the padded message stream is required.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 165px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 82.5px; transform-origin: 407px 82.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCreate binary represented state array (as the initial input to the sponge function (f)) from any length character array (N) with width (b=1600), digest length (d=224) and lane size (w=64) using SHA-3 Standard:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ehttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf    \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eConvert character array to binary representation using UTF-8 value of each character. Output state array will be a matrix with size (5,5,64). Padding in accordance with the standard is required. XOR of the rate bits (r) with the padded message stream is required (see figure 7, page 18). Just the first 1600 bit input to the first function (f) represented as a state array (see section 3.1.2) is required for the output.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function A = SHA3(N)\r\n  A=zeros(5,5,64);\r\nend","test_suite":"%%\r\nN = '';\r\nA='0110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';\r\nassert(isequal(SHA3(N),reshape(reshape(A-48,[64,25])',[5,5,64])))\r\n%%\r\nN = 'abcdefghijklmnopqrstuvwxyz';\r\nA='1110000000000000000000000100000000000000000000000001000000000000000000000000010000000000000000000000011000000000000000000000000100000000000000000000001110000000000000000000000111000000000000000000000010000000000000000000000000110000000000000000000000000000000000000000000000001000000000000000000000001110000000000000000000000011000000000000000000000011100000000000000000000001000000000000000000000000011000000000000000000000001000000000000000000000000010000000000000000000000101000000000000000000000011100000000000000000000001110000000000000000000000100000000000000000000000001100000000000000000000000110000000000000000000000100000000000000000000000001100000000000000000000000110000000000000000000000111000000000000000000000010000000000000000000000000110000000000000000000000011000000000000000000000011100000000000000000000000010000000000000000000000111000000000000000000000011100000000000000000000001010000000000000000000000010000000000000000000000001000000000000000000000001100000000000000000000000111000000000000000000000001100000000000000000000001110000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000010100000000000000000000001110000000000000000000000111000000000000000000000011100000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000100000000000000000000000011000000000000000000000011100000000000000000000001100000000000000000000000000000000000000000000000010000000000000000000000000100000000000000000000000000000000000000000000000011000000000000000000000001100000000000000010000000';\r\nassert(isequal(SHA3(N),reshape(A-48,[5,5,64])))\r\n%%\r\nN = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nA='1100100110010011000000000000101010010010011000000011001110100011111100000000101010011011101000000000010111111111000011000000001110110011000101100000000010000111010110100000000110100001010011100000000010110101100011100000000000001001001000100100000000000011001001111001000000010011000011100001100000000011000001100100110000000111110000100001110000000011001001100101110100000001101001100100111100000000000011110101110010000000010001110001110111100000001111110101011011110000000111100100111000111000000011111000110111111000000001110110110001111010000000110111111000111011000000010101110010111011000000000111110110001010100000000000111100011000001000000001111000001000001100000000110010011000111100000000110100011010011101000000010011111001011100000000000010011010001100100000000100111001011101101000000011101001101110101100000000101001011101101010000000011000010100000110000000011011111101101110100000001001010100111110010000000000111110010010101000000000000101001110010000000001100100001110001010000000011100000110010011000000011100001111100101000000000100010010000111000000000101001111100011011000000000100110011111100100000000100110001011000010000000001110101011100010000000001101010111001101100000000111010011011001100000000110010111001001111000000010110111101100110100000001010011101001100000000000011011001011101010000000010111011000101111000000001111001110101101010000000111011111100110110000000011010011100110110000000001010011100001010000000000001001100000011100000000011001110000010110000000000011100010110001010000000001100001110000111000000000100111111000111100000001100100111000001000000000';\r\nassert(isequal(SHA3(N),reshape(A-48,[5,5,64])))\r\n%%\r\nN = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods. Third, adjust all your means to that end.';\r\nA='1100010111000111000000000011011110001111011000000000101010111111011000000000111110110101011010000000110110001011111001000000010110000011001101100000000111000111001110110000000110000111000101110000000010100011010001100100000000001111100001100000000000110011001011101010000000000101011001100101100000000111001101110100010000000101010100110101110000000011101001100100010100000001000010100001110100000000101000101110010110000000000000100100111110000000000001100101110010010000000101100000010000101000000001110001011101011000000001100000010110101010000000100000110001001001000000010100110000111000100000000000110100101100010000000001110110001110001000000011010011011010011100000001011111011000101100000000110001101000011100000000010100111010010110100000001011111011001100000000000000011000101101100000000010011000001100101100000000001010001101000110000000011001101100101111000000001001101101010110000000001000011000101110100000000000001110101110011000000011011100001111111100000001001101001111010000000000001100011110011111000000001100011110011111000000000100100110000111010000000100001111011111101000000000011110000111001100000000111110011111010000000000001110011111111100000000001110110011000100100000000111010111010001100000000110000111000111100000000010110011000001100000000000010101001000101000000000110011001011110000000000001011000011100100100000000011010111100001100000000011011110101011111000000011011011111001110000000001000001100100110110000000011000100011111010000000000010111010110100000000000011100101110000110000000011110110110010111000000011101001111010111000000001100000111010001010000000';\r\nassert(isequal(SHA3(N),reshape(A-48,[5,5,64])))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-06-18T00:59:47.000Z","updated_at":"2025-10-16T14:21:12.000Z","published_at":"2019-08-28T19:00:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate binary represented state array (as the initial input to the sponge function (f)) from any length character array (N) with width (b=1600), digest length (d=224) and lane size (w=64) using SHA-3 Standard:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ehttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf    \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConvert character array to binary representation using UTF-8 value of each character. Output state array will be a matrix with size (5,5,64). Padding in accordance with the standard is required. XOR of the rate bits (r) with the padded message stream is required (see figure 7, page 18). Just the first 1600 bit input to the first function (f) represented as a state array (see section 3.1.2) is required for the output.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44965,"title":"Optimal Asymmetric Encryption Padding decoding of message for RSA Cryptography","description":"EME-OAEP decoding by reversing the Feistel network using previously determined mask generation function (MGF1) and SHA-1 hashing. A matrix of octets is provided as the input (EM) which is the output of EME-OAEP encoding (see problem 44964/below link 7.1.2 page 21). The label (L) is not provided or checked against the encoded label. No error checks should be conducted. Output should be the character string represented by the octets.\r\n\r\nFor example:\r\n\r\n  EM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\r\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\r\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\r\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\r\n148,12,50,108,248,32,94];%input\r\n  M = 'I like to swim.';%output\r\n\r\n\u003chttps://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf\u003e","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 275px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 137.5px; transform-origin: 407px 137.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eEME-OAEP decoding by reversing the Feistel network using previously determined mask generation function (MGF1) and SHA-1 hashing. A matrix of octets is provided as the input (EM) which is the output of EME-OAEP encoding (see problem 44964/below link, section 9.1.1.2). The label (L) is not provided or checked against the encoded label. No error checks should be conducted. Output should be the character string represented by the octets.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 120px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 60px; transform-origin: 404px 60px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(14, 0, 255); border-block-start-color: rgb(14, 0, 255); border-bottom-color: rgb(14, 0, 255); border-inline-end-color: rgb(14, 0, 255); border-inline-start-color: rgb(14, 0, 255); border-left-color: rgb(14, 0, 255); border-right-color: rgb(14, 0, 255); border-top-color: rgb(14, 0, 255); caret-color: rgb(14, 0, 255); color: rgb(14, 0, 255); column-rule-color: rgb(14, 0, 255); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(14, 0, 255); text-decoration: none; text-decoration-color: rgb(14, 0, 255); \"\u003e...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e148,12,50,108,248,32,94];\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%input\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10px; transform-origin: 404px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eM = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003e'I like to swim.'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e;\u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration: none; text-decoration-color: rgb(2, 128, 9); \"\u003e%output\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function  M  = EMEOAEPdecoding(EM)\r\n  M = 'I like to swim.';\r\nend","test_suite":"%%\r\nEM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,148,12,50,108,248,32,94];\r\nM = 'I like to swim.';\r\nassert(isequal(EMEOAEPdecoding(EM),M))\r\n%%\r\nEM = [0   145   194    62    62   111    86   188    50    37   165   231    16    42    25    79   223   177   117   187   135   200   203   136   184   133    38   175    66    35   142   212   144   116    66    37   151     8   190   218    29   238   213    11   189   225    88    83   218   175   183    98    58   237    89    80   123    64    40   154   137    44    13   186    97   133    92    11   228    32   100   188    61    37   150   198   178    73   252    17   133   233    68    13    39    99     3   239   108   106   202   227   127   142    79    34   126   244    41    92   240     8   127   153   251    25    82    79   247    92   187    51    84    38   104   240    52   209   144   160   144   119   131    67   128   116    98   132    51    79     8   114    69   202    80   243   194    61    17    33   225   232   173     5   153   230    32   155    34    62    72     2   211   212   227     5   115   217    33   189    21   170    51   190   217   119   148    73   209   109   114    90   104   237   168    60   144   120   191     7   186     8   205   111   192   249   192   197    34   225   209   153   234     5    27   165    82    42   132   167   158    64   218   239    71    49   166    27    37     9   154     2   255   193    72    75     7   121   121   240    74   116   185    58    79   106    68    14    17    49    68    96   160     2    75    15   122   144    36    47   230   112    39   221    21   141   251   178    10   215   180   230   184   189   112   108   187    83    94   157    69   140   201    40   158   119    28   159   116   196   206   112    91   141    68   122   113   183    92   111    44   149   187   223   179   157    29    79   180   231    38   122   231    82    98    42    69    14   162    53];\r\nM = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.';\r\nassert(isequal(EMEOAEPdecoding(EM),M))\r\n%%\r\nEM = [0    85    82   177   212   151     6   148    36   245   178   209   163    30    35   103   231   155   104   206    51   230   201    47   178   114   199    15   172   217   175    58    48   240   133     0   186   218    10   200    31   238   213    10   237   132    55    35   182   202   151    21    82   130   121    35    14    35    75   255   236    72    45   210     0   243    57    43   137    79     9   217    83    81   227   171   156   105   168   121   224   201    41    98    85     6    35   155     4    15   179   195    12   251    44    65    27   145    77   112   208   124    23   252   219   116    61    61   146   124   207    91    49    95    72   135    85   191   228   128   228    24   163    48   245    23     1   225    86    43    40    19    43   174   112   135   170    88    49    76   142   154   200    37   237   142    69   226     2    88    33   108   183   244   130    37     4   184    88   157    97   197    19   205   172    20   247    44   180     9    92   122    59   132   197    85   252    25   205   107   195    36   237    24   168   156   174   229    81   142   188   252   133   107   126   133    59    89   164   193   255    41   182   134    41    86   138    59    81    97   255    34   139   164    38    47    98    23    26   137   106    29   202    26    59     5   100   105   116    69   100    15   206    34    42    47    30   255    83    65   145    17    85   185    53   254   139   219   120   182   216   198   204   213    17    24   155    48    63   243   101   233   191    77   240    87   126   250    23   171   163    21   123   236   100     9    20   219    58    66    74   224   215   185   218   241   113    38   218   128     6    10   149    61    18    66    32   109   219    27   107   176    90   163   116    99    71    16   108    89   192   253   121   121    76   157   101   157   217    51    53   248   195    95    93   183    71    29   199     2   182    31   120    35   167    44   189   160     2   154   234   162   113   204    18   138    81   155    86   122   147    44    23   181    90   135    49   235    41   194    82   181    31    45   131    78   127   198   121   132    49     6   186    66   157   159    79   110   184   152    83   107    73    61    22    86   160   156   200   177    64   217    32   251   102     4   165   143   254   215   165   224   110    76    57    69    13   198   180   106   236    11    39   238     0   220    63   109   239   190    19    85    92    23    28   183   233    72    88   193     8   101   127   214   171     7    94   156   148   220    40    84    44   149     7   245   165   150   197    27    93   255   146    15   132   133   174   208     4   156   246    12    37    50    78    85    95   212   198    41    22   138   214   135   145   197   137   114   172   128    48   126   202   198     0    35    15    37   127     1    34    44   164    46   131    12    87   254     9   210   140    50    85   180   173   121    24    14   192   237    75   224    91   242   205   155     8   136    51    38   161     6   129   234    36     1    56   251    11     6    73    36    74   230    95   174    47    94    53   106   142    71   123    88    32    41     7   108    41   101    40   120   254   196    47   251    83   224   181   114   255   127    56     6   182   182   153   244   162   214   115   183   162    69    47   174   112    68    89   110   180    43    47   159   195   123    73   230   230   186   204   129   110   234   218   152    57   154   232    91    68   237   204   222   179   175   192   249     1   128     5   180    93    29    14    97   175   138   175   221   223   219    62    93   142    51   123   194    90     6   215    32   181    60    48    92   100   114    28   164    71   110   244   129   190   125    27   156   223   133     7   128    55   127    93     3    21    66    38   184    50    52     6   164   175    17   255   103    42    28   126    66    19   149    66     6   234   170   194   104    85    42   166   171   117   101    33    74    35   181    46   242   102   192   226   183   132   223   154    97   142   119   107     6    98    93   129   255   247   144   159    12   245   161   179    28     1   228    24    38   147    55   148    10   247   224   154   201   241    32    53    23   219    52     0   124    35    47    36    89   180    68    57   183   240    94   235    86   152   105    26   113    72    38    83   194   138    16    45   187    50   207   192   151    54    80   108   139   211   116   186   176    20   250    32   117   237   241   239   224   147   110    22   190    71    59    47    97     8   144   236   102     8   216   238   225    40   212   181   238   106   223    38   121   175    55    54   194   114   234   213    89    36   150   177   249    96   235    51    12   205    84   247   160    76];\r\nM = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.';\r\nassert(isequal(EMEOAEPdecoding(EM),M))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":145982,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-09-07T01:49:31.000Z","updated_at":"2025-10-15T13:23:25.000Z","published_at":"2019-09-07T01:56:46.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEME-OAEP decoding by reversing the Feistel network using previously determined mask generation function (MGF1) and SHA-1 hashing. A matrix of octets is provided as the input (EM) which is the output of EME-OAEP encoding (see problem 44964/below link, section 9.1.1.2). The label (L) is not provided or checked against the encoded label. No error checks should be conducted. Output should be the character string represented by the octets.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[EM = [0,167,202,74,98,63,234,235,44,82,53,39,70,214,204,79,45,80,35,147,55,32,35,39,45,...\\n87,180,129,63,219,223,165,72,19,131,160,131,131,107,231,157,238,213,10,237,132,55,...\\n35,182,202,151,21,82,130,121,35,14,35,75,255,236,72,45,210,0,243,57,43,137,79,9,...\\n217,83,81,227,171,156,105,168,121,224,201,41,98,84,79,3,247,109,100,214,227,120,...\\n148,12,50,108,248,32,94];%input\\nM = 'I like to swim.';%output]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee: https://www.foo.be/docs/opensst/ref/pkcs/pkcs-1/pkcs-1v2-1d1.pdf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"cryptography\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"cryptography\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"cryptography\"","","\"","cryptography","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f250ee13fe0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f250ee13f40\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f250ee13680\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f250ee14260\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f250ee141c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f250ee14120\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f250ee14080\u003e":"tag:\"cryptography\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f250ee14080\u003e":"tag:\"cryptography\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"cryptography\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"cryptography\"","","\"","cryptography","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f250ee13fe0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f250ee13f40\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f250ee13680\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f250ee14260\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f250ee141c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f250ee14120\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f250ee14080\u003e":"tag:\"cryptography\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f250ee14080\u003e":"tag:\"cryptography\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":55070,"difficulty_rating":"easy"},{"id":1151,"difficulty_rating":"easy"},{"id":45282,"difficulty_rating":"easy-medium"},{"id":1150,"difficulty_rating":"easy-medium"},{"id":54835,"difficulty_rating":"easy-medium"},{"id":751,"difficulty_rating":"easy-medium"},{"id":61050,"difficulty_rating":"easy-medium"},{"id":1953,"difficulty_rating":"easy-medium"},{"id":45279,"difficulty_rating":"easy-medium"},{"id":44351,"difficulty_rating":"medium"},{"id":45211,"difficulty_rating":"medium"},{"id":44356,"difficulty_rating":"medium"},{"id":78,"difficulty_rating":"medium"},{"id":44961,"difficulty_rating":"medium-hard"},{"id":44963,"difficulty_rating":"medium-hard"},{"id":44959,"difficulty_rating":"medium-hard"},{"id":45213,"difficulty_rating":"medium-hard"},{"id":44964,"difficulty_rating":"medium-hard"},{"id":44956,"difficulty_rating":"medium-hard"},{"id":44383,"difficulty_rating":"hard"},{"id":45212,"difficulty_rating":"hard"},{"id":44924,"difficulty_rating":"hard"},{"id":44965,"difficulty_rating":"hard"}]}}