{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-05-26T00:16:20.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-05-26T00: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":44884,"title":"Bridge and Torch Problem - Length of Unique Time List","description":"\u003chttps://en.wikipedia.org/wiki/Bridge_and_torch_problem Details of the problem ...\u003e \r\n\r\nInput is crossing time list. (for example x= [1 2 5 8])\r\n\r\nOutput is the length of all possible crossing time records. (for original problem y_correct= 14. In other words it is possible to cross the bridge in [15, 17, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31, 34, 40] minutes.\r\n\r\n*Assumption 1:* for this problem only four people will cross the bridge\r\n\r\n*Assumption 2:* crossing times are integer\r\n\r\n\r\n*Crossing Model:* 2 out of 4 people will cross the bridge, one of them will return. two out of 3 people will cross the bridge, one out of three people will return. Remaining two people will cross the bridge.","description_html":"\u003cp\u003e\u003ca href = \"https://en.wikipedia.org/wiki/Bridge_and_torch_problem\"\u003eDetails of the problem ...\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInput is crossing time list. (for example x= [1 2 5 8])\u003c/p\u003e\u003cp\u003eOutput is the length of all possible crossing time records. (for original problem y_correct= 14. In other words it is possible to cross the bridge in [15, 17, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31, 34, 40] minutes.\u003c/p\u003e\u003cp\u003e\u003cb\u003eAssumption 1:\u003c/b\u003e for this problem only four people will cross the bridge\u003c/p\u003e\u003cp\u003e\u003cb\u003eAssumption 2:\u003c/b\u003e crossing times are integer\u003c/p\u003e\u003cp\u003e\u003cb\u003eCrossing Model:\u003c/b\u003e 2 out of 4 people will cross the bridge, one of them will return. two out of 3 people will cross the bridge, one out of three people will return. Remaining two people will cross the bridge.\u003c/p\u003e","function_template":"function y = howManyWays(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('howManyWays.m');\r\nassert(isempty(strfind(filetext, 'assert')))\r\nassert(isempty(strfind(filetext, 'echo')))\r\n\r\n\r\n%%\r\nx = [1 1 1 1];\r\ny_correct = 1;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 1 1 10];\r\ny_correct = 3; %[14,32,50]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [12 24 24 30];\r\ny_correct = 5; %[102,114,126,138,150]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [22 34 34 43];\r\ny_correct = 6; %[155 167 179 185 197 215]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [6 6 10 12];\r\ny_correct = 7; %[36 40 44 48 52 56 60]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [6 6 7 8];\r\ny_correct = 8; %[32 33 34 35 36 37 38 40]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3 4 9 9];\r\ny_correct = 9; \r\nassert(isequal(howManyWays(x),y_correct))\r\n\r\n%%\r\nx = [4 6 8 11];\r\ny_correct = 10; \r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 5 6 7];\r\ny_correct = 13; \r\nassert(isequal(howManyWays(x),y_correct))\r\n\r\n\r\n%%\r\nx = [1 2 5 8];\r\ny_correct = 14;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 2 5 10];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 2 5 11];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [2 5 9 11];\r\ny_correct = 12;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3 8 13 16];\r\ny_correct = 11;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [7 13 15 16];\r\ny_correct = 11;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3 34 43 47];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [21 35 38 39];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [5 10 34 36];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [ 55 97 154 193];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [107 116 165 170];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [329 592 611 641];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3259 4164 5259 6544];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [5947 6267 8477 9254];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n\r\n%%\r\nx = [726 871 871 964];\r\ny_correct = 6; %[4158 4303 4448 4489 4634 4820]\r\nassert(isequal(howManyWays(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2019-04-22T11:56:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-04-21T07:08:50.000Z","updated_at":"2026-05-30T01:41:13.000Z","published_at":"2019-04-21T07:08:50.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:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Bridge_and_torch_problem\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDetails of the problem ...\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput is crossing time list. (for example x= [1 2 5 8])\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eOutput is the length of all possible crossing time records. (for original problem y_correct= 14. In other words it is possible to cross the bridge in [15, 17, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31, 34, 40] minutes.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eAssumption 1:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for this problem only four people will cross the bridge\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eAssumption 2:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e crossing times are integer\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eCrossing Model:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 2 out of 4 people will cross the bridge, one of them will return. two out of 3 people will cross the bridge, one out of three people will return. Remaining two people will cross the bridge.\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":{"problems":[{"id":44884,"title":"Bridge and Torch Problem - Length of Unique Time List","description":"\u003chttps://en.wikipedia.org/wiki/Bridge_and_torch_problem Details of the problem ...\u003e \r\n\r\nInput is crossing time list. (for example x= [1 2 5 8])\r\n\r\nOutput is the length of all possible crossing time records. (for original problem y_correct= 14. In other words it is possible to cross the bridge in [15, 17, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31, 34, 40] minutes.\r\n\r\n*Assumption 1:* for this problem only four people will cross the bridge\r\n\r\n*Assumption 2:* crossing times are integer\r\n\r\n\r\n*Crossing Model:* 2 out of 4 people will cross the bridge, one of them will return. two out of 3 people will cross the bridge, one out of three people will return. Remaining two people will cross the bridge.","description_html":"\u003cp\u003e\u003ca href = \"https://en.wikipedia.org/wiki/Bridge_and_torch_problem\"\u003eDetails of the problem ...\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInput is crossing time list. (for example x= [1 2 5 8])\u003c/p\u003e\u003cp\u003eOutput is the length of all possible crossing time records. (for original problem y_correct= 14. In other words it is possible to cross the bridge in [15, 17, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31, 34, 40] minutes.\u003c/p\u003e\u003cp\u003e\u003cb\u003eAssumption 1:\u003c/b\u003e for this problem only four people will cross the bridge\u003c/p\u003e\u003cp\u003e\u003cb\u003eAssumption 2:\u003c/b\u003e crossing times are integer\u003c/p\u003e\u003cp\u003e\u003cb\u003eCrossing Model:\u003c/b\u003e 2 out of 4 people will cross the bridge, one of them will return. two out of 3 people will cross the bridge, one out of three people will return. Remaining two people will cross the bridge.\u003c/p\u003e","function_template":"function y = howManyWays(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('howManyWays.m');\r\nassert(isempty(strfind(filetext, 'assert')))\r\nassert(isempty(strfind(filetext, 'echo')))\r\n\r\n\r\n%%\r\nx = [1 1 1 1];\r\ny_correct = 1;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 1 1 10];\r\ny_correct = 3; %[14,32,50]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [12 24 24 30];\r\ny_correct = 5; %[102,114,126,138,150]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [22 34 34 43];\r\ny_correct = 6; %[155 167 179 185 197 215]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [6 6 10 12];\r\ny_correct = 7; %[36 40 44 48 52 56 60]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [6 6 7 8];\r\ny_correct = 8; %[32 33 34 35 36 37 38 40]\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3 4 9 9];\r\ny_correct = 9; \r\nassert(isequal(howManyWays(x),y_correct))\r\n\r\n%%\r\nx = [4 6 8 11];\r\ny_correct = 10; \r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 5 6 7];\r\ny_correct = 13; \r\nassert(isequal(howManyWays(x),y_correct))\r\n\r\n\r\n%%\r\nx = [1 2 5 8];\r\ny_correct = 14;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 2 5 10];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [1 2 5 11];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [2 5 9 11];\r\ny_correct = 12;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3 8 13 16];\r\ny_correct = 11;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [7 13 15 16];\r\ny_correct = 11;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3 34 43 47];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [21 35 38 39];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [5 10 34 36];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [ 55 97 154 193];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [107 116 165 170];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [329 592 611 641];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [3259 4164 5259 6544];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n%%\r\nx = [5947 6267 8477 9254];\r\ny_correct = 15;\r\nassert(isequal(howManyWays(x),y_correct))\r\n\r\n%%\r\nx = [726 871 871 964];\r\ny_correct = 6; %[4158 4303 4448 4489 4634 4820]\r\nassert(isequal(howManyWays(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2019-04-22T11:56:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-04-21T07:08:50.000Z","updated_at":"2026-05-30T01:41:13.000Z","published_at":"2019-04-21T07:08:50.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:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Bridge_and_torch_problem\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDetails of the problem ...\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput is crossing time list. (for example x= [1 2 5 8])\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eOutput is the length of all possible crossing time records. (for original problem y_correct= 14. In other words it is possible to cross the bridge in [15, 17, 18, 19, 21, 22, 24, 25, 27, 28, 30, 31, 34, 40] minutes.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eAssumption 1:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for this problem only four people will cross the bridge\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eAssumption 2:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e crossing times are integer\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eCrossing Model:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 2 out of 4 people will cross the bridge, one of them will return. two out of 3 people will cross the bridge, one out of three people will return. Remaining two people will cross the bridge.\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\"}]}"}],"errors":[],"facets":[[],[{"value":"medium","count":1,"selected":false}]],"term":"tag:\"crossing time\"","page":1,"per_page":50,"sort":"map(difficulty_value,0,0,999) asc"}}