{"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":45244,"title":"How many Christmas presents under the tree? ","description":"For many families at Christmas, each family member gives 1 present to every other family member. The main exception is that children under the age of 16 do not contribute any presents. If there is only 1 child in the family, then that child is considered \"spoilt\" and receives 2 presents from each adult instead.\r\nGiven the size of a family (Nf) and the number of children under the age of 16 (Nc), find the number of presents under the Christmas tree!","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; 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: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; \"\u003e\u003cspan style=\"\"\u003eFor many families at Christmas, each family member gives 1 present to every other family member. The main exception is that children under the age of 16 do not contribute any presents. If there is only 1 child in the family, then that child is considered \"spoilt\" and receives 2 presents from each adult instead.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; \"\u003e\u003cspan style=\"\"\u003eGiven the size of a family (Nf) and the number of children under the age of 16 (Nc), find the number of presents under the Christmas tree!\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function Np = findPresents(Nf,Nc)\r\n    \r\nend","test_suite":"%%\r\nfam = 5;\r\nchldrn = 1;\r\ny_correct = 20;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))\r\n\r\n%%\r\nfam = 4;\r\nchldrn = 4;\r\ny_correct = 0;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))\r\n\r\n%%\r\nfam = 20;\r\nchldrn = 6;\r\ny_correct = 266;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))\r\n\r\n%%\r\nfam = 100;\r\nchldrn = 33;\r\ny_correct = 6633;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":359083,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":195,"test_suite_updated_at":"2021-10-24T02:01:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-12-23T09:21:12.000Z","updated_at":"2026-05-24T16:41:12.000Z","published_at":"2019-12-23T13:30:59.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor many families at Christmas, each family member gives 1 present to every other family member. The main exception is that children under the age of 16 do not contribute any presents. If there is only 1 child in the family, then that child is considered \\\"spoilt\\\" and receives 2 presents from each adult instead.\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\u003eGiven the size of a family (Nf) and the number of children under the age of 16 (Nc), find the number of presents under the Christmas tree!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"problems":[{"id":45244,"title":"How many Christmas presents under the tree? ","description":"For many families at Christmas, each family member gives 1 present to every other family member. The main exception is that children under the age of 16 do not contribute any presents. If there is only 1 child in the family, then that child is considered \"spoilt\" and receives 2 presents from each adult instead.\r\nGiven the size of a family (Nf) and the number of children under the age of 16 (Nc), find the number of presents under the Christmas tree!","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; 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: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; \"\u003e\u003cspan style=\"\"\u003eFor many families at Christmas, each family member gives 1 present to every other family member. The main exception is that children under the age of 16 do not contribute any presents. If there is only 1 child in the family, then that child is considered \"spoilt\" and receives 2 presents from each adult instead.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; \"\u003e\u003cspan style=\"\"\u003eGiven the size of a family (Nf) and the number of children under the age of 16 (Nc), find the number of presents under the Christmas tree!\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function Np = findPresents(Nf,Nc)\r\n    \r\nend","test_suite":"%%\r\nfam = 5;\r\nchldrn = 1;\r\ny_correct = 20;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))\r\n\r\n%%\r\nfam = 4;\r\nchldrn = 4;\r\ny_correct = 0;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))\r\n\r\n%%\r\nfam = 20;\r\nchldrn = 6;\r\ny_correct = 266;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))\r\n\r\n%%\r\nfam = 100;\r\nchldrn = 33;\r\ny_correct = 6633;\r\nassert(isequal(findPresents(fam,chldrn),y_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":359083,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":195,"test_suite_updated_at":"2021-10-24T02:01:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-12-23T09:21:12.000Z","updated_at":"2026-05-24T16:41:12.000Z","published_at":"2019-12-23T13:30:59.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor many families at Christmas, each family member gives 1 present to every other family member. The main exception is that children under the age of 16 do not contribute any presents. If there is only 1 child in the family, then that child is considered \\\"spoilt\\\" and receives 2 presents from each adult instead.\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\u003eGiven the size of a family (Nf) and the number of children under the age of 16 (Nc), find the number of presents under the Christmas tree!\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\"}]}"}],"errors":[],"facets":[[{"value":"Advent of Code","count":1,"selected":false}],[{"value":"medium","count":1,"selected":false}]],"term":"tag:\"trivia\"","page":1,"per_page":50,"sort":"map(difficulty_value,0,0,999) asc"}}