{"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":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":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":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":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\"}]}"}],"problem_search":{"errors":[],"problems":[{"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":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":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":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\"}]}"}],"term":"tag:\"decoding\"","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:\"decoding\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"decoding\"","","\"","decoding","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f732e44ddf8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f732e44dd58\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f732e44d498\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f732e44e078\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f732e44dfd8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f732e44df38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f732e44de98\u003e":"tag:\"decoding\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f732e44de98\u003e":"tag:\"decoding\""},"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:\"decoding\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"decoding\"","","\"","decoding","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f732e44ddf8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f732e44dd58\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f732e44d498\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f732e44e078\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f732e44dfd8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f732e44df38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f732e44de98\u003e":"tag:\"decoding\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f732e44de98\u003e":"tag:\"decoding\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":45282,"difficulty_rating":"easy-medium"},{"id":45279,"difficulty_rating":"easy-medium"},{"id":44351,"difficulty_rating":"medium"},{"id":44356,"difficulty_rating":"medium"},{"id":44383,"difficulty_rating":"hard"}]}}