{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.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":"2026-04-06T00: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":1734,"title":"Tiling a matrix","description":"Given a matrix and a number of columns, replicate matrix in a single row","description_html":"\u003cp\u003eGiven a matrix and a number of columns, replicate matrix in a single row\u003c/p\u003e","function_template":"function y = your_fcn_name(x,c)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 0;0 1];\r\nc=6\r\ny_correct = [1 0 1 0 1 0 1 0 1 0 1 0;0 1 0 1 0 1 0 1 0 1 0 1]\r\nassert(isequal(your_fcn_name(x,c),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":14448,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":179,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-22T11:55:20.000Z","updated_at":"2026-02-16T12:25:14.000Z","published_at":"2013-07-22T11:55:20.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a matrix and a number of columns, replicate matrix in a single row\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":2948,"title":"Create an m x n array consisting only of an input value.","description":"Create an array with m rows and n columns wherein all entries are assigned the input value x.","description_html":"\u003cp\u003eCreate an array with m rows and n columns wherein all entries are assigned the input value x.\u003c/p\u003e","function_template":"function y = array_x(m,n,x) \r\n y = x;\r\nend","test_suite":"%%\r\nm = 5; n = 4;\r\nx = 5;\r\ny_correct = [5 5 5 5; 5 5 5 5; 5 5 5 5; 5 5 5 5; 5 5 5 5]\r\nassert(isequal(array_x(m,n,x),y_correct));\r\n\r\n%%\r\nm = 4; n = 3;\r\nx = -7;\r\ny_correct = [-7 -7 -7; -7 -7 -7; -7 -7 -7; -7 -7 -7]\r\nassert(isequal(array_x(m,n,x),y_correct));\r\n\r\n%%\r\nm = 2; n = 6;\r\nx = 11;\r\ny_correct = [11 11 11 11 11 11; 11 11 11 11 11 11]\r\nassert(isequal(array_x(m,n,x),y_correct));\r\n\r\n%%\r\nm = 8; n = 1;\r\nx = 42;\r\ny_correct = [42; 42; 42; 42; 42; 42; 42; 42]\r\nassert(isequal(array_x(m,n,x),y_correct));","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":33771,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":85,"test_suite_updated_at":"2016-09-30T03:13:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-02-04T22:00:22.000Z","updated_at":"2026-02-18T10:01:00.000Z","published_at":"2015-02-04T22:04:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate an array with m rows and n columns wherein all entries are assigned the input value x.\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":1852,"title":"Repeat middle rows and columns of an array","description":"Given an MxN numeric array (A), return an array (B) in which the middle rows and columns have each been repeated once. It may be easier to think of this problem as two operations: (1) repeat the middle rows, and then (2) repeat the middle columns.\r\n\r\nThe motivation for this problem is to create an array that, when used in _blockproc(B,[2 2],fun)_, effectively incorporates a sliding window with 50% overlap. (NOTE: yes, _nlfilter_ will work on array A, but it requires that the processing output be a scalar, whereas _blockproc_ does not)\r\n\r\nYou may assume that M\u003e1, N\u003e1 (i.e. no scalars or vectors).\r\n\r\n*Example*\r\n\r\nIf\r\n\r\n  A = [1  2  3  4\r\n       5  6  7  8\r\n       9  10 11 12\r\n       13 14 15 16]\r\n\r\nThen\r\n\r\n\r\n  B = [1  2  2  3  3  4\r\n       5  6  6  7  7  8\r\n       5  6  6  7  7  8\r\n       9  10 10 11 11 12\r\n       9  10 10 11 11 12\r\n       13 14 14 15 15 16]","description_html":"\u003cp\u003eGiven an MxN numeric array (A), return an array (B) in which the middle rows and columns have each been repeated once. It may be easier to think of this problem as two operations: (1) repeat the middle rows, and then (2) repeat the middle columns.\u003c/p\u003e\u003cp\u003eThe motivation for this problem is to create an array that, when used in \u003ci\u003eblockproc(B,[2 2],fun)\u003c/i\u003e, effectively incorporates a sliding window with 50% overlap. (NOTE: yes, \u003ci\u003enlfilter\u003c/i\u003e will work on array A, but it requires that the processing output be a scalar, whereas \u003ci\u003eblockproc\u003c/i\u003e does not)\u003c/p\u003e\u003cp\u003eYou may assume that M\u003e1, N\u003e1 (i.e. no scalars or vectors).\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIf\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA = [1  2  3  4\r\n     5  6  7  8\r\n     9  10 11 12\r\n     13 14 15 16]\r\n\u003c/pre\u003e\u003cp\u003eThen\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eB = [1  2  2  3  3  4\r\n     5  6  6  7  7  8\r\n     5  6  6  7  7  8\r\n     9  10 10 11 11 12\r\n     9  10 10 11 11 12\r\n     13 14 14 15 15 16]\r\n\u003c/pre\u003e","function_template":"function B = repmatmid(A)\r\n  B = A;\r\nend","test_suite":"%%\r\nA = randi(100,2);\r\nassert(isequal(repmatmid(A),A))\r\n\r\n%%\r\nA = magic(3);\r\nB_correct = [8 1 1 6;\r\n             3 5 5 7;\r\n             3 5 5 7;\r\n             4 9 9 2];\r\nassert(isequal(repmatmid(A),B_correct))\r\n\r\n%%\r\nA = reshape(1:16,4,4);\r\nB_correct = [1 5 5 9  9  13;\r\n             2 6 6 10 10 14;\r\n             2 6 6 10 10 14;\r\n             3 7 7 11 11 15;\r\n             3 7 7 11 11 15;\r\n             4 8 8 12 12 16];\r\nassert(isequal(repmatmid(A),B_correct))\r\n\r\n%%\r\nA = eye(5);\r\nB_correct = [1 0 0 0 0 0 0 0;\r\n             0 1 1 0 0 0 0 0;\r\n             0 1 1 0 0 0 0 0;\r\n             0 0 0 1 1 0 0 0;\r\n             0 0 0 1 1 0 0 0;\r\n             0 0 0 0 0 1 1 0;\r\n             0 0 0 0 0 1 1 0;\r\n             0 0 0 0 0 0 0 1];\r\nassert(isequal(repmatmid(A),B_correct))\r\n\r\n%%\r\nA = randi(100,42);\r\nB = repmatmid(A);\r\nC = diff(B,1,1);\r\nD = diff(B,1,2);\r\nassert(all(all(C(2:2:end,:)==0)))\r\nassert(all(all(D(:,2:2:end)==0)))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":37,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-08-29T15:52:15.000Z","updated_at":"2025-09-17T16:57:42.000Z","published_at":"2013-08-29T15:52:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an MxN numeric array (A), return an array (B) in which the middle rows and columns have each been repeated once. It may be easier to think of this problem as two operations: (1) repeat the middle rows, and then (2) repeat the middle columns.\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 motivation for this problem is to create an array that, when used 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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eblockproc(B,[2 2],fun)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, effectively incorporates a sliding window with 50% overlap. (NOTE: yes,\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\u003enlfilter\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will work on array A, but it requires that the processing output be a scalar, whereas\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\u003eblockproc\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e does not)\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 may assume that M\u0026gt;1, N\u0026gt;1 (i.e. no scalars or vectors).\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\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A = [1  2  3  4\\n     5  6  7  8\\n     9  10 11 12\\n     13 14 15 16]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThen\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[B = [1  2  2  3  3  4\\n     5  6  6  7  7  8\\n     5  6  6  7  7  8\\n     9  10 10 11 11 12\\n     9  10 10 11 11 12\\n     13 14 14 15 15 16]]]\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":921,"title":"REPMAT  Enhancement - Faster for Large Row Replication of Vector ","description":"The Challenge is to modify repmat.m to maintain all of its normal functionality and enhance its performance for large row replication for both N=1 and N\u003e1 cases,\r\nB=repmat(A,M,N).  The size of A for enhancement cases is [1,n].\r\n\r\nFor cases of M\u003e 12,288,000 and n\u003c128 or N*n\u003c256 it is possible to perform an enhanced repmat in 40% of the time of repmat. The standard repmat takes 150% longer than repmatLV in certain cases on Cody (2.5 sec / 1 sec).\r\n\r\n*Input:* [A,M,N]  standard input for repmat\r\n\r\n* A: Vector (row or column) or an array\r\n* M: row duplication factor of A\r\n* N: column replication factor of A\r\n\r\n*Output:* B, Array of size [M*m,N*n] where [m,n]=size(A)\r\n\r\n*Score:* Performance is based upon time(msec) to execute four large row replications\r\n\r\nTest Cases include normal arrays for which the function must still maintain repmat capability and also the large test cases:\r\n\r\n* 1: r [1,12] of uint32, M=6144000, N=4\r\n* 2: r [1,12] of uint8, M=6144000, N=16\r\n* 3: r [1,48] of uint32, M=6144000, N=1\r\n* 4: r [1,48] of uint8, M=12288000, N=1\r\n* Test cases are sized to not hit the memory limit and clears are implemented.\r\n\r\n\r\n*Potential Path:*\r\n\r\nI suggest replicating repmat.m to a local folder and name it repmatLV.m. Create a shell that calls repmatLV as if it was repmat. Implement calls of the stressing test cases from the shell. Use the Profiler Tool to analyze where time is being consumed and devise alternative speed enhancements.\r\n\r\n# command window; open repmat\r\n# file: save as: to local folder with new name\r\n# Create Shell calling function\r\n# From the Editor/Shell; Tools: Open Profiler\r\n# From Profiler Window:  Start Profiling  (Fourth row top left)\r\n# Explore the results of the profiler windows\r\n\r\nNote: The above cases assume a 3GB system or better. Reduce M as necessary.\r\n\r\n\r\nThe overall goal of this challenge is to show that matlab built-in functions are excellent resources for methods, optimization of functions is possible depending on individual needs, and profiling is fun.\r\n\r\nA follow-up Challenge will demonstrate an optimization of ismember, for the 'sortrows' option with many rows, when both arrays have many rows vs columns and have low commonality(\u003c 10%). Processing time can be reduced by more than 90% for these large row dominant arrays compared to the standard ismember time. \r\n\r\n\r\nEnjoy.","description_html":"\u003cp\u003eThe Challenge is to modify repmat.m to maintain all of its normal functionality and enhance its performance for large row replication for both N=1 and N\u003e1 cases,\r\nB=repmat(A,M,N).  The size of A for enhancement cases is [1,n].\u003c/p\u003e\u003cp\u003eFor cases of M\u003e 12,288,000 and n\u0026lt;128 or N*n\u0026lt;256 it is possible to perform an enhanced repmat in 40% of the time of repmat. The standard repmat takes 150% longer than repmatLV in certain cases on Cody (2.5 sec / 1 sec).\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e [A,M,N]  standard input for repmat\u003c/p\u003e\u003cul\u003e\u003cli\u003eA: Vector (row or column) or an array\u003c/li\u003e\u003cli\u003eM: row duplication factor of A\u003c/li\u003e\u003cli\u003eN: column replication factor of A\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e B, Array of size [M*m,N*n] where [m,n]=size(A)\u003c/p\u003e\u003cp\u003e\u003cb\u003eScore:\u003c/b\u003e Performance is based upon time(msec) to execute four large row replications\u003c/p\u003e\u003cp\u003eTest Cases include normal arrays for which the function must still maintain repmat capability and also the large test cases:\u003c/p\u003e\u003cul\u003e\u003cli\u003e1: r [1,12] of uint32, M=6144000, N=4\u003c/li\u003e\u003cli\u003e2: r [1,12] of uint8, M=6144000, N=16\u003c/li\u003e\u003cli\u003e3: r [1,48] of uint32, M=6144000, N=1\u003c/li\u003e\u003cli\u003e4: r [1,48] of uint8, M=12288000, N=1\u003c/li\u003e\u003cli\u003eTest cases are sized to not hit the memory limit and clears are implemented.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003ePotential Path:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eI suggest replicating repmat.m to a local folder and name it repmatLV.m. Create a shell that calls repmatLV as if it was repmat. Implement calls of the stressing test cases from the shell. Use the Profiler Tool to analyze where time is being consumed and devise alternative speed enhancements.\u003c/p\u003e\u003col\u003e\u003cli\u003ecommand window; open repmat\u003c/li\u003e\u003cli\u003efile: save as: to local folder with new name\u003c/li\u003e\u003cli\u003eCreate Shell calling function\u003c/li\u003e\u003cli\u003eFrom the Editor/Shell; Tools: Open Profiler\u003c/li\u003e\u003cli\u003eFrom Profiler Window:  Start Profiling  (Fourth row top left)\u003c/li\u003e\u003cli\u003eExplore the results of the profiler windows\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eNote: The above cases assume a 3GB system or better. Reduce M as necessary.\u003c/p\u003e\u003cp\u003eThe overall goal of this challenge is to show that matlab built-in functions are excellent resources for methods, optimization of functions is possible depending on individual needs, and profiling is fun.\u003c/p\u003e\u003cp\u003eA follow-up Challenge will demonstrate an optimization of ismember, for the 'sortrows' option with many rows, when both arrays have many rows vs columns and have low commonality(\u0026lt; 10%). Processing time can be reduced by more than 90% for these large row dominant arrays compared to the standard ismember time.\u003c/p\u003e\u003cp\u003eEnjoy.\u003c/p\u003e","function_template":"function B = repmatLV(A,M,N)\r\n% B=repmat(A,M,N);  % Will create a Passing solution - but slow\r\n  B=A;\r\nend","test_suite":"%%\r\nfeval(@assignin,'caller','score',0);\r\n%%\r\n% Testing for standard repmat capability\r\na=magic(5);\r\nM=randi(4);\r\nN=randi(8);\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=5;\r\nM=randi(10);\r\nN=randi(10);\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=5;\r\nM=randi(10);\r\nN=1;\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=4;\r\nM=1;\r\nN=randi(10);\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=magic(8);\r\nM=2;\r\nN=2;\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\n%%\r\nM=1024;\r\nN=1;\r\nn=48;\r\nr=randi(255,1,n,'uint8');\r\n%r=double(r);\r\n\r\nfor i=1:5  % Routine warm-up\r\n  r_repmatLV=repmatLV(r,M,N);\r\nend\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=6144000;\r\nN=4;\r\nn=12;\r\nr=randi(2^31,1,n,'uint32');\r\n\r\nta=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt1=etime(clock,ta)*1000;\r\nP1=isequal(r(1,12),r_repmatLV(M,n*N));\r\nP2=isequal(r(1,12),r_repmatLV(randi(10000),36));\r\nassert(P1 \u0026\u0026 P2  \u0026\u0026 ~ P3  \u0026\u0026 ~P4)\r\n\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=6144000;\r\nN=16;\r\nn=12;\r\nr=randi(255,1,n,'uint8');\r\n\r\ntb=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt2=etime(clock,tb)*1000;\r\nP2=isequal(r(1,12),r_repmatLV(M,n*N));\r\nassert(P2 \u0026\u0026 ~P1  \u0026\u0026 ~ P3  \u0026\u0026 ~P4)\r\n\r\n\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=6144000;\r\nN=1;\r\nn=48;\r\nr=randi(2^31,1,n,'uint32');\r\n\r\ntc=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt3=etime(clock,tc)*1000;\r\nP3=isequal(r(1,1),r_repmatLV(M,1));\r\nassert(P3 \u0026\u0026 ~P1  \u0026\u0026 ~ P2  \u0026\u0026 ~P4)\r\n\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=12288000;\r\nN=1;\r\nn=48;\r\nr=randi(255,1,n,'uint8');\r\n\r\ntd=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt4=etime(clock,td)*1000;\r\nP4=isequal(r(1,48),r_repmatLV(1000000,48));\r\nassert(P4 \u0026\u0026 ~P3  \u0026\u0026 ~ P2  \u0026\u0026 ~P1)\r\n\r\nclear r_repmatLV\r\n% This checks for sub-optimal column processing\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=64;\r\nN=1;\r\nn=4000000;\r\nr=randi(255,1,n,'uint8');\r\n\r\nte=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt5=etime(clock,te)*1000;\r\nP5=isequal(r(1,n),r_repmatLV(M,n));\r\nassert(P5)\r\n\r\nfeval(@assignin,'caller','score',0);\r\nif P5\r\n sum_dt=min(15000,t1+t2+t3+t4+t5); % repmat scores 12000\r\n feval(@assignin,'caller','score',floor(sum_dt));\r\nend\r\n\r\nfprintf('Times: %.0f %.0f %.0f %.0f %.0f  Total %.0f msec\\n',t1,t2,t3,t4,t5,t1+t2+t3+t4+t5)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-08-25T20:11:30.000Z","updated_at":"2026-03-11T11:30:11.000Z","published_at":"2012-08-26T00:53:53.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\u003eThe Challenge is to modify repmat.m to maintain all of its normal functionality and enhance its performance for large row replication for both N=1 and N\u0026gt;1 cases, B=repmat(A,M,N). The size of A for enhancement cases is [1,n].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor cases of M\u0026gt; 12,288,000 and n\u0026lt;128 or N*n\u0026lt;256 it is possible to perform an enhanced repmat in 40% of the time of repmat. The standard repmat takes 150% longer than repmatLV in certain cases on Cody (2.5 sec / 1 sec).\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\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [A,M,N] standard input for repmat\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\u003eA: Vector (row or column) or an array\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\u003eM: row duplication factor of A\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\u003eN: column replication factor of A\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\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e B, Array of size [M*m,N*n] where [m,n]=size(A)\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\u003eScore:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Performance is based upon time(msec) to execute four large row replications\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\u003eTest Cases include normal arrays for which the function must still maintain repmat capability and also the large test cases:\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\u003e1: r [1,12] of uint32, M=6144000, N=4\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\u003e2: r [1,12] of uint8, M=6144000, N=16\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\u003e3: r [1,48] of uint32, M=6144000, N=1\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\u003e4: r [1,48] of uint8, M=12288000, N=1\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\u003eTest cases are sized to not hit the memory limit and clears are implemented.\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\u003ePotential Path:\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\u003eI suggest replicating repmat.m to a local folder and name it repmatLV.m. Create a shell that calls repmatLV as if it was repmat. Implement calls of the stressing test cases from the shell. Use the Profiler Tool to analyze where time is being consumed and devise alternative speed enhancements.\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\u003ecommand window; open repmat\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\u003efile: save as: to local folder with new name\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\u003eCreate Shell calling function\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\u003eFrom the Editor/Shell; Tools: Open Profiler\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\u003eFrom Profiler Window: Start Profiling (Fourth row top left)\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\u003eExplore the results of the profiler windows\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: The above cases assume a 3GB system or better. Reduce M as necessary.\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 overall goal of this challenge is to show that matlab built-in functions are excellent resources for methods, optimization of functions is possible depending on individual needs, and profiling is fun.\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\u003eA follow-up Challenge will demonstrate an optimization of ismember, for the 'sortrows' option with many rows, when both arrays have many rows vs columns and have low commonality(\u0026lt; 10%). Processing time can be reduced by more than 90% for these large row dominant arrays compared to the standard ismember time.\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\u003eEnjoy.\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":60651,"title":"ICFP2024 011:Lambdaman Small programmed solutions","description":"The ICFP2024 contest was held June29 thru July 1. The contest consisted of five parts: ICFP Language, Lambdaman maze, Starship flying, 3D - graph programming, and  Efficiency - processing complex ICFP message to a numerical value.\r\nThe Lambdaman 4 maze is medium size,21x21, L near top left,  '.' a cheese bit, # is Wall. Matrix uses Wall=0,L=1,Cheese=2. Encircling Walls are added to all mazes.\r\nThe contest goal was to write a minimal size, bytes, expression that moves L, Lambdaman, to eat each cheese bit.\r\nSolve these mazes while having a total file size including comments less than 1000.\r\n%Descriptions\r\n%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\r\n%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\r\n%6: size(1,200) with L at 1,1 199 Rs\r\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\r\n%9: size(50,50) with L at 1,1\r\n","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: 316.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 440.5px 158.3px; transform-origin: 440.5px 158.3px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14.5px 8px; transform-origin: 14.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://icfpcontest2024.github.io/task.html\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eICFP2024 contest\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 300px 8px; transform-origin: 300px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e was held June29 thru July 1. The contest consisted of five parts: ICFP Language, Lambdaman maze, Starship flying, 3D - graph programming, and  Efficiency - processing complex ICFP message to a numerical value.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 317.5px 8px; transform-origin: 317.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe Lambdaman 4 maze is medium size,21x21, L near top left,  '.' a cheese bit, # is Wall. Matrix uses Wall=0,L=1,Cheese=2. Encircling Walls are added to all mazes.\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: 357.5px 8px; transform-origin: 357.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe contest goal was to write a minimal size, bytes, expression that moves L, Lambdaman, to eat each cheese bit.\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: 260.5px 8px; transform-origin: 260.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSolve these mazes while having a total file size including comments less than 1000.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 437.5px 61.3px; transform-origin: 437.5px 61.3px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 437.5px 10.2167px; transform-origin: 437.5px 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: 52px 8.5px; tab-size: 4; transform-origin: 52px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%Descriptions\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 172px 8.5px; tab-size: 4; transform-origin: 172px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 412px 8.5px; tab-size: 4; transform-origin: 412px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 144px 8.5px; tab-size: 4; transform-origin: 144px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%6: size(1,200) with L at 1,1 199 Rs\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 304px 8.5px; tab-size: 4; transform-origin: 304px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 116px 8.5px; tab-size: 4; transform-origin: 116px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%9: size(50,50) with L at 1,1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [path]=case_solutions(m,ICFP_id)\r\n% This is pre-programmed solutions for multiple ICFP_ids\r\n%The goal is to minimize programming size and solve each ID\r\n%Total m size is limited and checked by test suite. No 10s allowed\r\n\r\n%Descriptions\r\n%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\r\n%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\r\n%6: size(1,200) with L at 1,1 199 Rs\r\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\r\n%9: size(50,50) with L at 1,1\r\nif ICFP_id==1\r\n path='UDLLLDURRRRRURR';\r\nelseif ICFP_id==5 \r\n path='';\r\nelseif ICFP_id==6 \r\n path='';\r\nelseif ICFP_id==8 \r\n path='';\r\nelseif ICFP_id==9\r\n path='';\r\nelse\r\n path='';\r\nend\r\n\r\nend % case solutions","test_suite":"%%\r\nvalid=1;\r\n%Accessing dir to get file size\r\nz=dir;\r\nzdata=struct2table(z);\r\nzdir_idx=find(strcmp(zdata.name,'case_solutions.m'));\r\nmsize=z(zdir_idx).bytes;\r\nif msize\u003e1000\r\n valid=0;\r\n fprintf('Fail m file size check of 1000. Your m file size is %i\\n\\n',msize)\r\nelse\r\n fprintf('Passed m file size check of 1000. With m file size being %i\\n\\n',msize)  \r\nend\r\n\r\n%Loop through cases \r\n%Descriptions\r\n% L lambdaman 1,   . Cheese 2,   # Wall 0\r\n%1: Small puzzle 15 moves: UDLLLDURRRRRURR\r\n%5: Spiral (11,16) L mid. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\r\n%6: size(1,200) with L at 1,1 199 Rs\r\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\r\n%9: Open square size(50,50) with L at 1,1\r\nfor m_id=[1 5 6 8 9]\r\n\r\nif m_id==1\r\n%Lambdaman 1  optimal solution L15\r\n   ms=['###.#...'\r\n       '...L..##'\r\n       '.#######'];\r\nelseif m_id==5\r\n   ms=[ ...\r\n'.....########...'\r\n'....#...........'\r\n'...#..######....'\r\n'..#..#......#...'\r\n'.#..#...##...#..'\r\n'.#..#..#L.#...#.'\r\n'.#...#....#...#.'\r\n'..#...####...#..'\r\n'...#........#...'\r\n'....########....'\r\n'................'];\r\nelseif m_id==6\r\n ms=repelem('.',200);\r\n ms(1)='L';\r\nelseif m_id==8\r\n      ms=[...\r\n'###################################################################################################'\r\n'#.................................................................................................#'\r\n'#.###############################################################################################.#'\r\n'#.#.............................................................................................#.#'\r\n'#.#.###########################################################################################.#.#'\r\n'#.#.#.........................................................................................#.#.#'\r\n'#.#.#.#######################################################################################.#.#.#'\r\n'#.#.#.#.....................................................................................#.#.#.#'\r\n'#.#.#.#.###################################################################################.#.#.#.#'\r\n'#.#.#.#.#.................................................................................#.#.#.#.#'\r\n'#.#.#.#.#.###############################################################################.#.#.#.#.#'\r\n'#.#.#.#.#.#.............................................................................#.#.#.#.#.#'\r\n'#.#.#.#.#.#.###########################################################################.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.........................................................................#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#######################################################################.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.....................................................................#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.###################################################################.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.................................................................#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.###############################################################.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.............................................................#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.###########################################################.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.........................................................#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#######################################################.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.....................................................#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.###################################################.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.................................................#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.###############################################.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.............................................#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.###########################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.........................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.....................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###############################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.............................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###########################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.........................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.....................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###############.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.............#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###########.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.........#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.....#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#L#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.......#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#########.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...........#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#############.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...............#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#####################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.......................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#########################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...........................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#############################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...............................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#####################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.......................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#########################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#...........................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#############################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#...............................................#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#################################################.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#...................................................#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#####################################################.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.......................................................#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#########################################################.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#...........................................................#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#############################################################.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#...............................................................#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#################################################################.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#...................................................................#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#####################################################################.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.......................................................................#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#########################################################################.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#...........................................................................#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#############################################################################.#.#.#.#.#.#'\r\n'#.#.#.#.#...............................................................................#.#.#.#.#.#'\r\n'#.#.#.#.#################################################################################.#.#.#.#.#'\r\n'#.#.#.#...................................................................................#.#.#.#.#'\r\n'#.#.#.#####################################################################################.#.#.#.#'\r\n'#.#.#.......................................................................................#.#.#.#'\r\n'#.#.#########################################################################################.#.#.#'\r\n'#.#...........................................................................................#.#.#'\r\n'#.#############################################################################################.#.#'\r\n'#...............................................................................................#.#'\r\n'#################################################################################################.#'\r\n'..................................................................................................#'\r\n'###################################################################################################'];\r\nelse\r\n %9: Open square size(50,50) with L at 1,1\r\n ms=repmat('.',50,50);\r\n ms(1)='L'; \r\nend % m+id cases\r\n\r\n[nr,nc]=size(ms);\r\nmb=ones(nr,nc)*2; %Cheese bits are 2.\r\nmb(ms=='#')=0; % Wall\r\nmb(ms=='L')=1; % Landaman, start point\r\nm=zeros(nr+2,nc+2);\r\nm(2:end-1,2:end-1)=mb; %Wall surrounded maze\r\n[nr,nc]=size(m);\r\n\r\nzmap=[0 0 0;1 0 0;0 1 0;0 0 1]; % maps to 1:4\r\nfigure;image(m+1);colormap(zmap);axis equal;axis tight\r\n\r\nztic=tic;\r\nv = case_solutions(m,m_id);\r\n\r\nfprintf('Answer Length: %i  Time:%.2f\\n',length(v),toc(ztic));\r\n%fprintf('Path:');fprintf('%s',v);fprintf('\\n')\r\n\r\nmc=m==2; %Create cheese binary matrix for processing path coverage\r\n\r\n[r,c]=find(m==1); % Lambdaman\r\nfor i=1:length(v)\r\n if v(i)=='R' % R\r\n  if c+1\u003c=nc\r\n    if m(r,c+1)\u003e0\r\n     c=c+1;\r\n    end\r\n  end\r\n elseif v(i)=='L' % L\r\n  if c-1\u003e=1\r\n    if m(r,c-1)\u003e0\r\n     c=c-1;\r\n    end\r\n  end\r\n elseif v(i)=='U' % U\r\n  if r-1\u003e=1\r\n   if m(r-1,c)\u003e0\r\n     r=r-1;\r\n   end\r\n  end\r\n elseif v(i)=='D' % D\r\n  if r+1\u003c=nr\r\n    if m(r+1,c)\u003e0\r\n     r=r+1;\r\n    end\r\n  end\r\n end\r\n mc(r,c)=0; \r\n if nnz(mc)==0,break;end\r\nend\r\n\r\nif nnz(mc)\u003e0\r\n  valid=0;\r\n  fprintf('In ICFP %i Failed to Clear - remaining cheesy bits\\n',m_id);\r\nelse\r\n  fprintf('Passed ICFP %i\\n\\n',m_id)\r\nend\r\n\r\nend % for m_id\r\n\r\nassert(valid)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":3097,"edited_at":"2024-07-18T18:19:17.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2024-07-18T17:00:26.000Z","updated_at":"2024-07-18T18:19:18.000Z","published_at":"2024-07-18T18:16:55.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\u003eThe \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://icfpcontest2024.github.io/task.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eICFP2024 contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e was held June29 thru July 1. The contest consisted of five parts: ICFP Language, Lambdaman maze, Starship flying, 3D - graph programming, and  Efficiency - processing complex ICFP message to a numerical value.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Lambdaman 4 maze is medium size,21x21, L near top left,  '.' a cheese bit, # is Wall. Matrix uses Wall=0,L=1,Cheese=2. Encircling Walls are added to all mazes.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe contest goal was to write a minimal size, bytes, expression that moves L, Lambdaman, to eat each cheese bit.\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\u003eSolve these mazes while having a total file size including comments less than 1000.\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[%Descriptions\\n%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\\n%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\\n%6: size(1,200) with L at 1,1 199 Rs\\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\\n%9: size(50,50) with L at 1,1]]\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\u003e\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":1042,"title":"Operate on matrices of unequal, yet similar, size","description":"You may want to add a vector to a matrix, implying that the vector is added to each column of the matrix. Or multiply a 3x4x5 matrix with a 3x4 matrix, intending to do that for every element in the 3th dimension. \r\n\r\n  \u003e\u003e [1 2;3 4].*[1 2]\r\n  \r\n  ans =\r\n  \r\n     1     4\r\n     3     8\r\n\r\nIt's clear what you want to do, but Matlab is very strict and gives an error, unless you first make the size of the arguments match.\r\n\r\nYou will now create a function that operates on two arguments, performing one of the operations 'plus', 'minus', 'times', 'power', 'ldivide' or 'rdivide' (specified as the 3rd argument), after it has matched the sizes of first two input arguments.\r\n\r\nIt should work on input arguments of more than two dimensions, of arguments of different dimensions, as long as they are numerical matrices, vectors, or values.\r\n\r\nThere is one limitation: for dimensions in which the size of the input arguments differ, the size of one of them should be one.\r\n\r\nNote: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.","description_html":"\u003cp\u003eYou may want to add a vector to a matrix, implying that the vector is added to each column of the matrix. Or multiply a 3x4x5 matrix with a 3x4 matrix, intending to do that for every element in the 3th dimension.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u003e\u003e [1 2;3 4].*[1 2]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eans =\r\n\u003c/pre\u003e\u003cpre\u003e     1     4\r\n     3     8\u003c/pre\u003e\u003cp\u003eIt's clear what you want to do, but Matlab is very strict and gives an error, unless you first make the size of the arguments match.\u003c/p\u003e\u003cp\u003eYou will now create a function that operates on two arguments, performing one of the operations 'plus', 'minus', 'times', 'power', 'ldivide' or 'rdivide' (specified as the 3rd argument), after it has matched the sizes of first two input arguments.\u003c/p\u003e\u003cp\u003eIt should work on input arguments of more than two dimensions, of arguments of different dimensions, as long as they are numerical matrices, vectors, or values.\u003c/p\u003e\u003cp\u003eThere is one limitation: for dimensions in which the size of the input arguments differ, the size of one of them should be one.\u003c/p\u003e\u003cp\u003eNote: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.\u003c/p\u003e","function_template":"function z = matched_op(x,y,op)\r\n  z = feval(op,x,y);\r\nend","test_suite":"%%\r\nnocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)'));\r\nx = [1 2;3 4];\r\ny = [1 2];\r\nz_correct = [1 4;3 8];\r\nassert(isequal(matched_op(x,y,'times'),z_correct) \u0026\u0026 nocheat)\r\n\r\n%%\r\nnocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)'));\r\nx = [10i];\r\ny = [20];\r\nz_correct = [-2i];\r\nassert(isequal(matched_op(x,y,'ldivide'),z_correct) \u0026\u0026 nocheat)\r\n\r\n%%\r\nnocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)'));\r\nx = reshape(1:4,[1 1 1 4]);\r\ny = (1:4).';\r\nz_correct = reshape([2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8],[4 1 1 4]);\r\nassert(isequal(matched_op(x,y,'plus'),z_correct) \u0026\u0026 nocheat)\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":229,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":19,"created_at":"2012-11-20T09:59:22.000Z","updated_at":"2026-03-15T18:54:46.000Z","published_at":"2012-11-20T09:59:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou may want to add a vector to a matrix, implying that the vector is added to each column of the matrix. Or multiply a 3x4x5 matrix with a 3x4 matrix, intending to do that for every element in the 3th dimension.\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[\u003e\u003e [1 2;3 4].*[1 2]\\n\\nans =\\n\\n     1     4\\n     3     8]]\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\u003eIt's clear what you want to do, but Matlab is very strict and gives an error, unless you first make the size of the arguments match.\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 will now create a function that operates on two arguments, performing one of the operations 'plus', 'minus', 'times', 'power', 'ldivide' or 'rdivide' (specified as the 3rd argument), after it has matched the sizes of first two input arguments.\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\u003eIt should work on input arguments of more than two dimensions, of arguments of different dimensions, as long as they are numerical matrices, vectors, or values.\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\u003eThere is one limitation: for dimensions in which the size of the input arguments differ, the size of one of them should be one.\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: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.\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":1734,"title":"Tiling a matrix","description":"Given a matrix and a number of columns, replicate matrix in a single row","description_html":"\u003cp\u003eGiven a matrix and a number of columns, replicate matrix in a single row\u003c/p\u003e","function_template":"function y = your_fcn_name(x,c)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 0;0 1];\r\nc=6\r\ny_correct = [1 0 1 0 1 0 1 0 1 0 1 0;0 1 0 1 0 1 0 1 0 1 0 1]\r\nassert(isequal(your_fcn_name(x,c),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":14448,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":179,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-22T11:55:20.000Z","updated_at":"2026-02-16T12:25:14.000Z","published_at":"2013-07-22T11:55:20.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a matrix and a number of columns, replicate matrix in a single row\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":2948,"title":"Create an m x n array consisting only of an input value.","description":"Create an array with m rows and n columns wherein all entries are assigned the input value x.","description_html":"\u003cp\u003eCreate an array with m rows and n columns wherein all entries are assigned the input value x.\u003c/p\u003e","function_template":"function y = array_x(m,n,x) \r\n y = x;\r\nend","test_suite":"%%\r\nm = 5; n = 4;\r\nx = 5;\r\ny_correct = [5 5 5 5; 5 5 5 5; 5 5 5 5; 5 5 5 5; 5 5 5 5]\r\nassert(isequal(array_x(m,n,x),y_correct));\r\n\r\n%%\r\nm = 4; n = 3;\r\nx = -7;\r\ny_correct = [-7 -7 -7; -7 -7 -7; -7 -7 -7; -7 -7 -7]\r\nassert(isequal(array_x(m,n,x),y_correct));\r\n\r\n%%\r\nm = 2; n = 6;\r\nx = 11;\r\ny_correct = [11 11 11 11 11 11; 11 11 11 11 11 11]\r\nassert(isequal(array_x(m,n,x),y_correct));\r\n\r\n%%\r\nm = 8; n = 1;\r\nx = 42;\r\ny_correct = [42; 42; 42; 42; 42; 42; 42; 42]\r\nassert(isequal(array_x(m,n,x),y_correct));","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":33771,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":85,"test_suite_updated_at":"2016-09-30T03:13:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-02-04T22:00:22.000Z","updated_at":"2026-02-18T10:01:00.000Z","published_at":"2015-02-04T22:04:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate an array with m rows and n columns wherein all entries are assigned the input value x.\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":1852,"title":"Repeat middle rows and columns of an array","description":"Given an MxN numeric array (A), return an array (B) in which the middle rows and columns have each been repeated once. It may be easier to think of this problem as two operations: (1) repeat the middle rows, and then (2) repeat the middle columns.\r\n\r\nThe motivation for this problem is to create an array that, when used in _blockproc(B,[2 2],fun)_, effectively incorporates a sliding window with 50% overlap. (NOTE: yes, _nlfilter_ will work on array A, but it requires that the processing output be a scalar, whereas _blockproc_ does not)\r\n\r\nYou may assume that M\u003e1, N\u003e1 (i.e. no scalars or vectors).\r\n\r\n*Example*\r\n\r\nIf\r\n\r\n  A = [1  2  3  4\r\n       5  6  7  8\r\n       9  10 11 12\r\n       13 14 15 16]\r\n\r\nThen\r\n\r\n\r\n  B = [1  2  2  3  3  4\r\n       5  6  6  7  7  8\r\n       5  6  6  7  7  8\r\n       9  10 10 11 11 12\r\n       9  10 10 11 11 12\r\n       13 14 14 15 15 16]","description_html":"\u003cp\u003eGiven an MxN numeric array (A), return an array (B) in which the middle rows and columns have each been repeated once. It may be easier to think of this problem as two operations: (1) repeat the middle rows, and then (2) repeat the middle columns.\u003c/p\u003e\u003cp\u003eThe motivation for this problem is to create an array that, when used in \u003ci\u003eblockproc(B,[2 2],fun)\u003c/i\u003e, effectively incorporates a sliding window with 50% overlap. (NOTE: yes, \u003ci\u003enlfilter\u003c/i\u003e will work on array A, but it requires that the processing output be a scalar, whereas \u003ci\u003eblockproc\u003c/i\u003e does not)\u003c/p\u003e\u003cp\u003eYou may assume that M\u003e1, N\u003e1 (i.e. no scalars or vectors).\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIf\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA = [1  2  3  4\r\n     5  6  7  8\r\n     9  10 11 12\r\n     13 14 15 16]\r\n\u003c/pre\u003e\u003cp\u003eThen\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eB = [1  2  2  3  3  4\r\n     5  6  6  7  7  8\r\n     5  6  6  7  7  8\r\n     9  10 10 11 11 12\r\n     9  10 10 11 11 12\r\n     13 14 14 15 15 16]\r\n\u003c/pre\u003e","function_template":"function B = repmatmid(A)\r\n  B = A;\r\nend","test_suite":"%%\r\nA = randi(100,2);\r\nassert(isequal(repmatmid(A),A))\r\n\r\n%%\r\nA = magic(3);\r\nB_correct = [8 1 1 6;\r\n             3 5 5 7;\r\n             3 5 5 7;\r\n             4 9 9 2];\r\nassert(isequal(repmatmid(A),B_correct))\r\n\r\n%%\r\nA = reshape(1:16,4,4);\r\nB_correct = [1 5 5 9  9  13;\r\n             2 6 6 10 10 14;\r\n             2 6 6 10 10 14;\r\n             3 7 7 11 11 15;\r\n             3 7 7 11 11 15;\r\n             4 8 8 12 12 16];\r\nassert(isequal(repmatmid(A),B_correct))\r\n\r\n%%\r\nA = eye(5);\r\nB_correct = [1 0 0 0 0 0 0 0;\r\n             0 1 1 0 0 0 0 0;\r\n             0 1 1 0 0 0 0 0;\r\n             0 0 0 1 1 0 0 0;\r\n             0 0 0 1 1 0 0 0;\r\n             0 0 0 0 0 1 1 0;\r\n             0 0 0 0 0 1 1 0;\r\n             0 0 0 0 0 0 0 1];\r\nassert(isequal(repmatmid(A),B_correct))\r\n\r\n%%\r\nA = randi(100,42);\r\nB = repmatmid(A);\r\nC = diff(B,1,1);\r\nD = diff(B,1,2);\r\nassert(all(all(C(2:2:end,:)==0)))\r\nassert(all(all(D(:,2:2:end)==0)))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":37,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-08-29T15:52:15.000Z","updated_at":"2025-09-17T16:57:42.000Z","published_at":"2013-08-29T15:52:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an MxN numeric array (A), return an array (B) in which the middle rows and columns have each been repeated once. It may be easier to think of this problem as two operations: (1) repeat the middle rows, and then (2) repeat the middle columns.\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 motivation for this problem is to create an array that, when used 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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eblockproc(B,[2 2],fun)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, effectively incorporates a sliding window with 50% overlap. (NOTE: yes,\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\u003enlfilter\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e will work on array A, but it requires that the processing output be a scalar, whereas\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\u003eblockproc\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e does not)\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 may assume that M\u0026gt;1, N\u0026gt;1 (i.e. no scalars or vectors).\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\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A = [1  2  3  4\\n     5  6  7  8\\n     9  10 11 12\\n     13 14 15 16]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThen\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[B = [1  2  2  3  3  4\\n     5  6  6  7  7  8\\n     5  6  6  7  7  8\\n     9  10 10 11 11 12\\n     9  10 10 11 11 12\\n     13 14 14 15 15 16]]]\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":921,"title":"REPMAT  Enhancement - Faster for Large Row Replication of Vector ","description":"The Challenge is to modify repmat.m to maintain all of its normal functionality and enhance its performance for large row replication for both N=1 and N\u003e1 cases,\r\nB=repmat(A,M,N).  The size of A for enhancement cases is [1,n].\r\n\r\nFor cases of M\u003e 12,288,000 and n\u003c128 or N*n\u003c256 it is possible to perform an enhanced repmat in 40% of the time of repmat. The standard repmat takes 150% longer than repmatLV in certain cases on Cody (2.5 sec / 1 sec).\r\n\r\n*Input:* [A,M,N]  standard input for repmat\r\n\r\n* A: Vector (row or column) or an array\r\n* M: row duplication factor of A\r\n* N: column replication factor of A\r\n\r\n*Output:* B, Array of size [M*m,N*n] where [m,n]=size(A)\r\n\r\n*Score:* Performance is based upon time(msec) to execute four large row replications\r\n\r\nTest Cases include normal arrays for which the function must still maintain repmat capability and also the large test cases:\r\n\r\n* 1: r [1,12] of uint32, M=6144000, N=4\r\n* 2: r [1,12] of uint8, M=6144000, N=16\r\n* 3: r [1,48] of uint32, M=6144000, N=1\r\n* 4: r [1,48] of uint8, M=12288000, N=1\r\n* Test cases are sized to not hit the memory limit and clears are implemented.\r\n\r\n\r\n*Potential Path:*\r\n\r\nI suggest replicating repmat.m to a local folder and name it repmatLV.m. Create a shell that calls repmatLV as if it was repmat. Implement calls of the stressing test cases from the shell. Use the Profiler Tool to analyze where time is being consumed and devise alternative speed enhancements.\r\n\r\n# command window; open repmat\r\n# file: save as: to local folder with new name\r\n# Create Shell calling function\r\n# From the Editor/Shell; Tools: Open Profiler\r\n# From Profiler Window:  Start Profiling  (Fourth row top left)\r\n# Explore the results of the profiler windows\r\n\r\nNote: The above cases assume a 3GB system or better. Reduce M as necessary.\r\n\r\n\r\nThe overall goal of this challenge is to show that matlab built-in functions are excellent resources for methods, optimization of functions is possible depending on individual needs, and profiling is fun.\r\n\r\nA follow-up Challenge will demonstrate an optimization of ismember, for the 'sortrows' option with many rows, when both arrays have many rows vs columns and have low commonality(\u003c 10%). Processing time can be reduced by more than 90% for these large row dominant arrays compared to the standard ismember time. \r\n\r\n\r\nEnjoy.","description_html":"\u003cp\u003eThe Challenge is to modify repmat.m to maintain all of its normal functionality and enhance its performance for large row replication for both N=1 and N\u003e1 cases,\r\nB=repmat(A,M,N).  The size of A for enhancement cases is [1,n].\u003c/p\u003e\u003cp\u003eFor cases of M\u003e 12,288,000 and n\u0026lt;128 or N*n\u0026lt;256 it is possible to perform an enhanced repmat in 40% of the time of repmat. The standard repmat takes 150% longer than repmatLV in certain cases on Cody (2.5 sec / 1 sec).\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e [A,M,N]  standard input for repmat\u003c/p\u003e\u003cul\u003e\u003cli\u003eA: Vector (row or column) or an array\u003c/li\u003e\u003cli\u003eM: row duplication factor of A\u003c/li\u003e\u003cli\u003eN: column replication factor of A\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e B, Array of size [M*m,N*n] where [m,n]=size(A)\u003c/p\u003e\u003cp\u003e\u003cb\u003eScore:\u003c/b\u003e Performance is based upon time(msec) to execute four large row replications\u003c/p\u003e\u003cp\u003eTest Cases include normal arrays for which the function must still maintain repmat capability and also the large test cases:\u003c/p\u003e\u003cul\u003e\u003cli\u003e1: r [1,12] of uint32, M=6144000, N=4\u003c/li\u003e\u003cli\u003e2: r [1,12] of uint8, M=6144000, N=16\u003c/li\u003e\u003cli\u003e3: r [1,48] of uint32, M=6144000, N=1\u003c/li\u003e\u003cli\u003e4: r [1,48] of uint8, M=12288000, N=1\u003c/li\u003e\u003cli\u003eTest cases are sized to not hit the memory limit and clears are implemented.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003ePotential Path:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eI suggest replicating repmat.m to a local folder and name it repmatLV.m. Create a shell that calls repmatLV as if it was repmat. Implement calls of the stressing test cases from the shell. Use the Profiler Tool to analyze where time is being consumed and devise alternative speed enhancements.\u003c/p\u003e\u003col\u003e\u003cli\u003ecommand window; open repmat\u003c/li\u003e\u003cli\u003efile: save as: to local folder with new name\u003c/li\u003e\u003cli\u003eCreate Shell calling function\u003c/li\u003e\u003cli\u003eFrom the Editor/Shell; Tools: Open Profiler\u003c/li\u003e\u003cli\u003eFrom Profiler Window:  Start Profiling  (Fourth row top left)\u003c/li\u003e\u003cli\u003eExplore the results of the profiler windows\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eNote: The above cases assume a 3GB system or better. Reduce M as necessary.\u003c/p\u003e\u003cp\u003eThe overall goal of this challenge is to show that matlab built-in functions are excellent resources for methods, optimization of functions is possible depending on individual needs, and profiling is fun.\u003c/p\u003e\u003cp\u003eA follow-up Challenge will demonstrate an optimization of ismember, for the 'sortrows' option with many rows, when both arrays have many rows vs columns and have low commonality(\u0026lt; 10%). Processing time can be reduced by more than 90% for these large row dominant arrays compared to the standard ismember time.\u003c/p\u003e\u003cp\u003eEnjoy.\u003c/p\u003e","function_template":"function B = repmatLV(A,M,N)\r\n% B=repmat(A,M,N);  % Will create a Passing solution - but slow\r\n  B=A;\r\nend","test_suite":"%%\r\nfeval(@assignin,'caller','score',0);\r\n%%\r\n% Testing for standard repmat capability\r\na=magic(5);\r\nM=randi(4);\r\nN=randi(8);\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=5;\r\nM=randi(10);\r\nN=randi(10);\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=5;\r\nM=randi(10);\r\nN=1;\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=4;\r\nM=1;\r\nN=randi(10);\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\na=magic(8);\r\nM=2;\r\nN=2;\r\nassert(isequal(repmat(a,M,N),repmatLV(a,M,N)));\r\n%%\r\nM=1024;\r\nN=1;\r\nn=48;\r\nr=randi(255,1,n,'uint8');\r\n%r=double(r);\r\n\r\nfor i=1:5  % Routine warm-up\r\n  r_repmatLV=repmatLV(r,M,N);\r\nend\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=6144000;\r\nN=4;\r\nn=12;\r\nr=randi(2^31,1,n,'uint32');\r\n\r\nta=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt1=etime(clock,ta)*1000;\r\nP1=isequal(r(1,12),r_repmatLV(M,n*N));\r\nP2=isequal(r(1,12),r_repmatLV(randi(10000),36));\r\nassert(P1 \u0026\u0026 P2  \u0026\u0026 ~ P3  \u0026\u0026 ~P4)\r\n\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=6144000;\r\nN=16;\r\nn=12;\r\nr=randi(255,1,n,'uint8');\r\n\r\ntb=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt2=etime(clock,tb)*1000;\r\nP2=isequal(r(1,12),r_repmatLV(M,n*N));\r\nassert(P2 \u0026\u0026 ~P1  \u0026\u0026 ~ P3  \u0026\u0026 ~P4)\r\n\r\n\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=6144000;\r\nN=1;\r\nn=48;\r\nr=randi(2^31,1,n,'uint32');\r\n\r\ntc=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt3=etime(clock,tc)*1000;\r\nP3=isequal(r(1,1),r_repmatLV(M,1));\r\nassert(P3 \u0026\u0026 ~P1  \u0026\u0026 ~ P2  \u0026\u0026 ~P4)\r\n\r\n\r\nclear r_repmatLV\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=12288000;\r\nN=1;\r\nn=48;\r\nr=randi(255,1,n,'uint8');\r\n\r\ntd=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt4=etime(clock,td)*1000;\r\nP4=isequal(r(1,48),r_repmatLV(1000000,48));\r\nassert(P4 \u0026\u0026 ~P3  \u0026\u0026 ~ P2  \u0026\u0026 ~P1)\r\n\r\nclear r_repmatLV\r\n% This checks for sub-optimal column processing\r\nP1=false; P2=false; P3=false;P4=false;\r\nM=64;\r\nN=1;\r\nn=4000000;\r\nr=randi(255,1,n,'uint8');\r\n\r\nte=clock;\r\n r_repmatLV=repmatLV(r,M,N);\r\nt5=etime(clock,te)*1000;\r\nP5=isequal(r(1,n),r_repmatLV(M,n));\r\nassert(P5)\r\n\r\nfeval(@assignin,'caller','score',0);\r\nif P5\r\n sum_dt=min(15000,t1+t2+t3+t4+t5); % repmat scores 12000\r\n feval(@assignin,'caller','score',floor(sum_dt));\r\nend\r\n\r\nfprintf('Times: %.0f %.0f %.0f %.0f %.0f  Total %.0f msec\\n',t1,t2,t3,t4,t5,t1+t2+t3+t4+t5)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-08-25T20:11:30.000Z","updated_at":"2026-03-11T11:30:11.000Z","published_at":"2012-08-26T00:53:53.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\u003eThe Challenge is to modify repmat.m to maintain all of its normal functionality and enhance its performance for large row replication for both N=1 and N\u0026gt;1 cases, B=repmat(A,M,N). The size of A for enhancement cases is [1,n].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor cases of M\u0026gt; 12,288,000 and n\u0026lt;128 or N*n\u0026lt;256 it is possible to perform an enhanced repmat in 40% of the time of repmat. The standard repmat takes 150% longer than repmatLV in certain cases on Cody (2.5 sec / 1 sec).\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\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e [A,M,N] standard input for repmat\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\u003eA: Vector (row or column) or an array\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\u003eM: row duplication factor of A\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\u003eN: column replication factor of A\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\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e B, Array of size [M*m,N*n] where [m,n]=size(A)\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\u003eScore:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Performance is based upon time(msec) to execute four large row replications\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\u003eTest Cases include normal arrays for which the function must still maintain repmat capability and also the large test cases:\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\u003e1: r [1,12] of uint32, M=6144000, N=4\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\u003e2: r [1,12] of uint8, M=6144000, N=16\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\u003e3: r [1,48] of uint32, M=6144000, N=1\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\u003e4: r [1,48] of uint8, M=12288000, N=1\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\u003eTest cases are sized to not hit the memory limit and clears are implemented.\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\u003ePotential Path:\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\u003eI suggest replicating repmat.m to a local folder and name it repmatLV.m. Create a shell that calls repmatLV as if it was repmat. Implement calls of the stressing test cases from the shell. Use the Profiler Tool to analyze where time is being consumed and devise alternative speed enhancements.\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\u003ecommand window; open repmat\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\u003efile: save as: to local folder with new name\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\u003eCreate Shell calling function\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\u003eFrom the Editor/Shell; Tools: Open Profiler\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\u003eFrom Profiler Window: Start Profiling (Fourth row top left)\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\u003eExplore the results of the profiler windows\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: The above cases assume a 3GB system or better. Reduce M as necessary.\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 overall goal of this challenge is to show that matlab built-in functions are excellent resources for methods, optimization of functions is possible depending on individual needs, and profiling is fun.\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\u003eA follow-up Challenge will demonstrate an optimization of ismember, for the 'sortrows' option with many rows, when both arrays have many rows vs columns and have low commonality(\u0026lt; 10%). Processing time can be reduced by more than 90% for these large row dominant arrays compared to the standard ismember time.\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\u003eEnjoy.\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":60651,"title":"ICFP2024 011:Lambdaman Small programmed solutions","description":"The ICFP2024 contest was held June29 thru July 1. The contest consisted of five parts: ICFP Language, Lambdaman maze, Starship flying, 3D - graph programming, and  Efficiency - processing complex ICFP message to a numerical value.\r\nThe Lambdaman 4 maze is medium size,21x21, L near top left,  '.' a cheese bit, # is Wall. Matrix uses Wall=0,L=1,Cheese=2. Encircling Walls are added to all mazes.\r\nThe contest goal was to write a minimal size, bytes, expression that moves L, Lambdaman, to eat each cheese bit.\r\nSolve these mazes while having a total file size including comments less than 1000.\r\n%Descriptions\r\n%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\r\n%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\r\n%6: size(1,200) with L at 1,1 199 Rs\r\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\r\n%9: size(50,50) with L at 1,1\r\n","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: 316.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 440.5px 158.3px; transform-origin: 440.5px 158.3px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 14.5px 8px; transform-origin: 14.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://icfpcontest2024.github.io/task.html\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eICFP2024 contest\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 300px 8px; transform-origin: 300px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e was held June29 thru July 1. The contest consisted of five parts: ICFP Language, Lambdaman maze, Starship flying, 3D - graph programming, and  Efficiency - processing complex ICFP message to a numerical value.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 317.5px 8px; transform-origin: 317.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe Lambdaman 4 maze is medium size,21x21, L near top left,  '.' a cheese bit, # is Wall. Matrix uses Wall=0,L=1,Cheese=2. Encircling Walls are added to all mazes.\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: 357.5px 8px; transform-origin: 357.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe contest goal was to write a minimal size, bytes, expression that moves L, Lambdaman, to eat each cheese bit.\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: 260.5px 8px; transform-origin: 260.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSolve these mazes while having a total file size including comments less than 1000.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 437.5px 61.3px; transform-origin: 437.5px 61.3px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 437.5px 10.2167px; transform-origin: 437.5px 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: 52px 8.5px; tab-size: 4; transform-origin: 52px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%Descriptions\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 172px 8.5px; tab-size: 4; transform-origin: 172px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 412px 8.5px; tab-size: 4; transform-origin: 412px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 144px 8.5px; tab-size: 4; transform-origin: 144px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%6: size(1,200) with L at 1,1 199 Rs\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 304px 8.5px; tab-size: 4; transform-origin: 304px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\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: 437.5px 10.2167px; transform-origin: 437.5px 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: 116px 8.5px; tab-size: 4; transform-origin: 116px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"border-block-end-color: rgb(2, 128, 9); border-block-start-color: rgb(2, 128, 9); border-bottom-color: rgb(2, 128, 9); border-inline-end-color: rgb(2, 128, 9); border-inline-start-color: rgb(2, 128, 9); border-left-color: rgb(2, 128, 9); border-right-color: rgb(2, 128, 9); border-top-color: rgb(2, 128, 9); caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9); column-rule-color: rgb(2, 128, 9); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(2, 128, 9); text-decoration-color: rgb(2, 128, 9); text-emphasis-color: rgb(2, 128, 9); \"\u003e%9: size(50,50) with L at 1,1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [path]=case_solutions(m,ICFP_id)\r\n% This is pre-programmed solutions for multiple ICFP_ids\r\n%The goal is to minimize programming size and solve each ID\r\n%Total m size is limited and checked by test suite. No 10s allowed\r\n\r\n%Descriptions\r\n%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\r\n%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\r\n%6: size(1,200) with L at 1,1 199 Rs\r\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\r\n%9: size(50,50) with L at 1,1\r\nif ICFP_id==1\r\n path='UDLLLDURRRRRURR';\r\nelseif ICFP_id==5 \r\n path='';\r\nelseif ICFP_id==6 \r\n path='';\r\nelseif ICFP_id==8 \r\n path='';\r\nelseif ICFP_id==9\r\n path='';\r\nelse\r\n path='';\r\nend\r\n\r\nend % case solutions","test_suite":"%%\r\nvalid=1;\r\n%Accessing dir to get file size\r\nz=dir;\r\nzdata=struct2table(z);\r\nzdir_idx=find(strcmp(zdata.name,'case_solutions.m'));\r\nmsize=z(zdir_idx).bytes;\r\nif msize\u003e1000\r\n valid=0;\r\n fprintf('Fail m file size check of 1000. Your m file size is %i\\n\\n',msize)\r\nelse\r\n fprintf('Passed m file size check of 1000. With m file size being %i\\n\\n',msize)  \r\nend\r\n\r\n%Loop through cases \r\n%Descriptions\r\n% L lambdaman 1,   . Cheese 2,   # Wall 0\r\n%1: Small puzzle 15 moves: UDLLLDURRRRRURR\r\n%5: Spiral (11,16) L mid. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\r\n%6: size(1,200) with L at 1,1 199 Rs\r\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\r\n%9: Open square size(50,50) with L at 1,1\r\nfor m_id=[1 5 6 8 9]\r\n\r\nif m_id==1\r\n%Lambdaman 1  optimal solution L15\r\n   ms=['###.#...'\r\n       '...L..##'\r\n       '.#######'];\r\nelseif m_id==5\r\n   ms=[ ...\r\n'.....########...'\r\n'....#...........'\r\n'...#..######....'\r\n'..#..#......#...'\r\n'.#..#...##...#..'\r\n'.#..#..#L.#...#.'\r\n'.#...#....#...#.'\r\n'..#...####...#..'\r\n'...#........#...'\r\n'....########....'\r\n'................'];\r\nelseif m_id==6\r\n ms=repelem('.',200);\r\n ms(1)='L';\r\nelseif m_id==8\r\n      ms=[...\r\n'###################################################################################################'\r\n'#.................................................................................................#'\r\n'#.###############################################################################################.#'\r\n'#.#.............................................................................................#.#'\r\n'#.#.###########################################################################################.#.#'\r\n'#.#.#.........................................................................................#.#.#'\r\n'#.#.#.#######################################################################################.#.#.#'\r\n'#.#.#.#.....................................................................................#.#.#.#'\r\n'#.#.#.#.###################################################################################.#.#.#.#'\r\n'#.#.#.#.#.................................................................................#.#.#.#.#'\r\n'#.#.#.#.#.###############################################################################.#.#.#.#.#'\r\n'#.#.#.#.#.#.............................................................................#.#.#.#.#.#'\r\n'#.#.#.#.#.#.###########################################################################.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.........................................................................#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#######################################################################.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.....................................................................#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.###################################################################.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.................................................................#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.###############################################################.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.............................................................#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.###########################################################.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.........................................................#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#######################################################.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.....................................................#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.###################################################.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.................................................#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.###############################################.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.............................................#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.###########################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.........................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.....................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###############################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.............................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###########################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.........................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.....................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###############.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.............#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###########.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.........#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.....#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#L#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.......#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#########.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...........#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#############.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...............#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#####################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.......................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#########################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...........................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#############################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...............................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#####################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.......................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#.#########################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#...........................................#.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#.#############################################.#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#...............................................#.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#.#################################################.#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#...................................................#.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.#####################################################.#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#.......................................................#.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#.#########################################################.#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#...........................................................#.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#.#############################################################.#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#...............................................................#.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#.#################################################################.#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#...................................................................#.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.#####################################################################.#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#.......................................................................#.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#.#########################################################################.#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#...........................................................................#.#.#.#.#.#.#'\r\n'#.#.#.#.#.#############################################################################.#.#.#.#.#.#'\r\n'#.#.#.#.#...............................................................................#.#.#.#.#.#'\r\n'#.#.#.#.#################################################################################.#.#.#.#.#'\r\n'#.#.#.#...................................................................................#.#.#.#.#'\r\n'#.#.#.#####################################################################################.#.#.#.#'\r\n'#.#.#.......................................................................................#.#.#.#'\r\n'#.#.#########################################################################################.#.#.#'\r\n'#.#...........................................................................................#.#.#'\r\n'#.#############################################################################################.#.#'\r\n'#...............................................................................................#.#'\r\n'#################################################################################################.#'\r\n'..................................................................................................#'\r\n'###################################################################################################'];\r\nelse\r\n %9: Open square size(50,50) with L at 1,1\r\n ms=repmat('.',50,50);\r\n ms(1)='L'; \r\nend % m+id cases\r\n\r\n[nr,nc]=size(ms);\r\nmb=ones(nr,nc)*2; %Cheese bits are 2.\r\nmb(ms=='#')=0; % Wall\r\nmb(ms=='L')=1; % Landaman, start point\r\nm=zeros(nr+2,nc+2);\r\nm(2:end-1,2:end-1)=mb; %Wall surrounded maze\r\n[nr,nc]=size(m);\r\n\r\nzmap=[0 0 0;1 0 0;0 1 0;0 0 1]; % maps to 1:4\r\nfigure;image(m+1);colormap(zmap);axis equal;axis tight\r\n\r\nztic=tic;\r\nv = case_solutions(m,m_id);\r\n\r\nfprintf('Answer Length: %i  Time:%.2f\\n',length(v),toc(ztic));\r\n%fprintf('Path:');fprintf('%s',v);fprintf('\\n')\r\n\r\nmc=m==2; %Create cheese binary matrix for processing path coverage\r\n\r\n[r,c]=find(m==1); % Lambdaman\r\nfor i=1:length(v)\r\n if v(i)=='R' % R\r\n  if c+1\u003c=nc\r\n    if m(r,c+1)\u003e0\r\n     c=c+1;\r\n    end\r\n  end\r\n elseif v(i)=='L' % L\r\n  if c-1\u003e=1\r\n    if m(r,c-1)\u003e0\r\n     c=c-1;\r\n    end\r\n  end\r\n elseif v(i)=='U' % U\r\n  if r-1\u003e=1\r\n   if m(r-1,c)\u003e0\r\n     r=r-1;\r\n   end\r\n  end\r\n elseif v(i)=='D' % D\r\n  if r+1\u003c=nr\r\n    if m(r+1,c)\u003e0\r\n     r=r+1;\r\n    end\r\n  end\r\n end\r\n mc(r,c)=0; \r\n if nnz(mc)==0,break;end\r\nend\r\n\r\nif nnz(mc)\u003e0\r\n  valid=0;\r\n  fprintf('In ICFP %i Failed to Clear - remaining cheesy bits\\n',m_id);\r\nelse\r\n  fprintf('Passed ICFP %i\\n\\n',m_id)\r\nend\r\n\r\nend % for m_id\r\n\r\nassert(valid)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":3097,"edited_at":"2024-07-18T18:19:17.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2024-07-18T17:00:26.000Z","updated_at":"2024-07-18T18:19:18.000Z","published_at":"2024-07-18T18:16:55.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\u003eThe \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://icfpcontest2024.github.io/task.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eICFP2024 contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e was held June29 thru July 1. The contest consisted of five parts: ICFP Language, Lambdaman maze, Starship flying, 3D - graph programming, and  Efficiency - processing complex ICFP message to a numerical value.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Lambdaman 4 maze is medium size,21x21, L near top left,  '.' a cheese bit, # is Wall. Matrix uses Wall=0,L=1,Cheese=2. Encircling Walls are added to all mazes.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe contest goal was to write a minimal size, bytes, expression that moves L, Lambdaman, to eat each cheese bit.\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\u003eSolve these mazes while having a total file size including comments less than 1000.\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[%Descriptions\\n%1: Small puzzle 15 moves: UDLLLLDURRRRRURR\\n%5: Spiral (11,16) L at middle. ICFP best repeated  'LUURRDDRRDLUDDDLLRDDDLLLLULULLURRRRULURU' 27 times\\n%6: size(1,200) with L at 1,1 199 Rs\\n%8: Spiral(100,100) L at middle. Counter clockwise starting with D to escape\\n%9: size(50,50) with L at 1,1]]\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\u003e\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":1042,"title":"Operate on matrices of unequal, yet similar, size","description":"You may want to add a vector to a matrix, implying that the vector is added to each column of the matrix. Or multiply a 3x4x5 matrix with a 3x4 matrix, intending to do that for every element in the 3th dimension. \r\n\r\n  \u003e\u003e [1 2;3 4].*[1 2]\r\n  \r\n  ans =\r\n  \r\n     1     4\r\n     3     8\r\n\r\nIt's clear what you want to do, but Matlab is very strict and gives an error, unless you first make the size of the arguments match.\r\n\r\nYou will now create a function that operates on two arguments, performing one of the operations 'plus', 'minus', 'times', 'power', 'ldivide' or 'rdivide' (specified as the 3rd argument), after it has matched the sizes of first two input arguments.\r\n\r\nIt should work on input arguments of more than two dimensions, of arguments of different dimensions, as long as they are numerical matrices, vectors, or values.\r\n\r\nThere is one limitation: for dimensions in which the size of the input arguments differ, the size of one of them should be one.\r\n\r\nNote: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.","description_html":"\u003cp\u003eYou may want to add a vector to a matrix, implying that the vector is added to each column of the matrix. Or multiply a 3x4x5 matrix with a 3x4 matrix, intending to do that for every element in the 3th dimension.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u003e\u003e [1 2;3 4].*[1 2]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eans =\r\n\u003c/pre\u003e\u003cpre\u003e     1     4\r\n     3     8\u003c/pre\u003e\u003cp\u003eIt's clear what you want to do, but Matlab is very strict and gives an error, unless you first make the size of the arguments match.\u003c/p\u003e\u003cp\u003eYou will now create a function that operates on two arguments, performing one of the operations 'plus', 'minus', 'times', 'power', 'ldivide' or 'rdivide' (specified as the 3rd argument), after it has matched the sizes of first two input arguments.\u003c/p\u003e\u003cp\u003eIt should work on input arguments of more than two dimensions, of arguments of different dimensions, as long as they are numerical matrices, vectors, or values.\u003c/p\u003e\u003cp\u003eThere is one limitation: for dimensions in which the size of the input arguments differ, the size of one of them should be one.\u003c/p\u003e\u003cp\u003eNote: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.\u003c/p\u003e","function_template":"function z = matched_op(x,y,op)\r\n  z = feval(op,x,y);\r\nend","test_suite":"%%\r\nnocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)'));\r\nx = [1 2;3 4];\r\ny = [1 2];\r\nz_correct = [1 4;3 8];\r\nassert(isequal(matched_op(x,y,'times'),z_correct) \u0026\u0026 nocheat)\r\n\r\n%%\r\nnocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)'));\r\nx = [10i];\r\ny = [20];\r\nz_correct = [-2i];\r\nassert(isequal(matched_op(x,y,'ldivide'),z_correct) \u0026\u0026 nocheat)\r\n\r\n%%\r\nnocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)'));\r\nx = reshape(1:4,[1 1 1 4]);\r\ny = (1:4).';\r\nz_correct = reshape([2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8],[4 1 1 4]);\r\nassert(isequal(matched_op(x,y,'plus'),z_correct) \u0026\u0026 nocheat)\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":229,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":19,"created_at":"2012-11-20T09:59:22.000Z","updated_at":"2026-03-15T18:54:46.000Z","published_at":"2012-11-20T09:59:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou may want to add a vector to a matrix, implying that the vector is added to each column of the matrix. Or multiply a 3x4x5 matrix with a 3x4 matrix, intending to do that for every element in the 3th dimension.\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[\u003e\u003e [1 2;3 4].*[1 2]\\n\\nans =\\n\\n     1     4\\n     3     8]]\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\u003eIt's clear what you want to do, but Matlab is very strict and gives an error, unless you first make the size of the arguments match.\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 will now create a function that operates on two arguments, performing one of the operations 'plus', 'minus', 'times', 'power', 'ldivide' or 'rdivide' (specified as the 3rd argument), after it has matched the sizes of first two input arguments.\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\u003eIt should work on input arguments of more than two dimensions, of arguments of different dimensions, as long as they are numerical matrices, vectors, or values.\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\u003eThere is one limitation: for dimensions in which the size of the input arguments differ, the size of one of them should be one.\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: Solutions wrapped in eval(c), inline, str2func, regexprep (dynamic regular expressions), etc, are not appreciated.\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:\"repmat\"","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:\"repmat\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"repmat\"","","\"","repmat","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9cee0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f2f60b9ce40\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9c580\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9d160\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f2f60b9d0c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f2f60b9d020\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f2f60b9cf80\u003e":"tag:\"repmat\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9cf80\u003e":"tag:\"repmat\""},"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":"cody-search","password":"78X075ddcV44","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:\"repmat\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"repmat\"","","\"","repmat","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9cee0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f2f60b9ce40\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9c580\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9d160\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f2f60b9d0c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f2f60b9d020\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f2f60b9cf80\u003e":"tag:\"repmat\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f2f60b9cf80\u003e":"tag:\"repmat\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":1734,"difficulty_rating":"easy"},{"id":2948,"difficulty_rating":"easy"},{"id":1852,"difficulty_rating":"easy-medium"},{"id":921,"difficulty_rating":"easy-medium"},{"id":60651,"difficulty_rating":"easy-medium"},{"id":1042,"difficulty_rating":"medium"}]}}