{"group":{"group":{"id":679,"name":"Project Euler IV","lockable":false,"created_at":"2019-05-02T18:51:49.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"More problems inspired by Project Euler.","is_default":false,"created_by":26769,"badge_id":62,"featured":false,"trending":false,"solution_count_in_trending_period":38,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":452,"published":true,"community_created":true,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"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\u003eMore problems inspired by Project Euler.\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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.5px; transform-origin: 289.5px 10.5px; \"\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; perspective-origin: 266.5px 10.5px; transform-origin: 266.5px 10.5px; 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; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eMore problems inspired by Project Euler.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-07-08T15:19:37.000Z"},"current_player":null},"problems":[{"id":42377,"title":"Bouncy numbers","description":"Inspired by Project Euler n°112.\r\n\r\nWorking from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number. For example: 134468.\r\n\r\nSimilarly if no digit is exceeded by the digit to its right it is called a decreasing number. For example: 66420.\r\nWe shall call a positive integer that is neither increasing nor decreasing a bouncy number. For example, 155349.\r\nClearly there cannot be any bouncy numbers below one-hundred, but surprisingly, these numbers become more and more common after.\r\nFind the least number for which the proportion of bouncy numbers is exactly p%.\r\nAs always this type of problem is difficult to solve with usual Matlab functions (num2str).\r\nSo keep an eye on time...","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: 315.167px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 157.583px; transform-origin: 407px 157.583px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 99.5px 8px; transform-origin: 99.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInspired by Project Euler n°112.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 102.167px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 51.0833px; transform-origin: 391px 51.0833px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003c/li\u003e\u003cli style=\"block-size: 40.8667px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 20.4333px; text-align: left; transform-origin: 363px 20.4333px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 256.5px 8px; transform-origin: 256.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWorking from left-to-right if no digit is exceeded by the digit to its left it is called an\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 66px 8px; transform-origin: 66px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eincreasing number\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 17px 8px; transform-origin: 17px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. For example: 134468.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 204.5px 8px; transform-origin: 204.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSimilarly if no digit is exceeded by the digit to its right it is called a\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 39.5px 8px; transform-origin: 39.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003edecreasing\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 94.5px 8px; transform-origin: 94.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e number. For example: 66420.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\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: 230.5px 8px; transform-origin: 230.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWe shall call a positive integer that is neither increasing nor decreasing a\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003ebouncy\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 98.5px 8px; transform-origin: 98.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e number. For example, 155349.\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: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eClearly there cannot be any bouncy numbers below one-hundred, but surprisingly, these numbers become more and more common after.\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: 252.5px 8px; transform-origin: 252.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFind the least number for which the proportion of bouncy numbers is exactly p%.\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: 273.5px 8px; transform-origin: 273.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAs always this type of problem is difficult to solve with usual Matlab functions (num2str).\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: 80.5px 8px; transform-origin: 80.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSo keep an eye on time...\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = bouncy_numbers(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 0.01;\r\ny_correct = 102;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.05;\r\ny_correct = 106;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.1;\r\ny_correct = 132;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.2;\r\ny_correct = 175;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.5;\r\ny_correct = 538;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.8;\r\ny_correct = 4770;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.9;\r\ny_correct = 21780;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.95;\r\ny_correct = 63720;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.96;\r\ny_correct = 152975;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.97;\r\ny_correct = 208200;\r\nassert(isequal(bouncy_numbers(x),y_correct))\r\n%%\r\nx = 0.98;\r\ny_correct = 377650;\r\nassert(isequal(bouncy_numbers(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":45,"test_suite_updated_at":"2021-07-22T06:29:35.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-06-14T23:04:12.000Z","updated_at":"2026-03-16T15:11:37.000Z","published_at":"2015-06-14T23:09:36.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInspired by Project Euler n°112.\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWorking from left-to-right if no digit is exceeded by the digit to its left it is called an\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eincreasing number\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. For example: 134468.\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSimilarly if no digit is exceeded by the digit to its right it is called a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edecreasing\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number. For example: 66420.\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\u003eWe shall call a positive integer that is neither increasing nor decreasing a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ebouncy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number. For example, 155349.\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\u003eClearly there cannot be any bouncy numbers below one-hundred, but surprisingly, these numbers become more and more common after.\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\u003eFind the least number for which the proportion of bouncy numbers is exactly p%.\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\u003eAs always this type of problem is difficult to solve with usual Matlab functions (num2str).\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\u003eSo keep an eye on time...\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":2674,"title":"Generalised Hamming Number","description":"Inspired by Project Euler n°204 and Problem 1308 by James\r\n\r\nA generalised Hamming number of type n, has no prime factor larger than n.\r\n\r\nFor example a generalised Hamming number of type 5 has no prime factor larger than 5.\r\n\r\nGiven a number X, determine how many generalised Hamming numbers n are less than or equal to that number. Please note that 1 counts as a Hamming number. \r\n\r\n\r\n","description_html":"\u003cp\u003eInspired by Project Euler n°204 and Problem 1308 by James\u003c/p\u003e\u003cp\u003eA generalised Hamming number of type n, has no prime factor larger than n.\u003c/p\u003e\u003cp\u003eFor example a generalised Hamming number of type 5 has no prime factor larger than 5.\u003c/p\u003e\u003cp\u003eGiven a number X, determine how many generalised Hamming numbers n are less than or equal to that number. Please note that 1 counts as a Hamming number.\u003c/p\u003e","function_template":"function y = hamming2(X,n)\r\n  X=n;\r\nend","test_suite":"%%\r\nX = 5;\r\nn=5;\r\ny_correct = 5;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 10;\r\nn=5;\r\ny_correct = 9;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 100;\r\nn=5;\r\ny_correct = 34;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 100;\r\nn=7;\r\ny_correct = 46;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 100;\r\nn=100;\r\ny_correct = 100;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 100;\r\nn=13;\r\ny_correct = 62;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 10^13;\r\nn=7;\r\ny_correct = 19674;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 10^5;\r\nn=13;\r\ny_correct = 1848;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 10^5;\r\nn=5;\r\ny_correct = 313;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 123456;\r\nn=5;\r\ny_correct = 327;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 10^13;\r\nn=3;\r\ny_correct = 624;\r\nassert(isequal(hamming2(X,n),y_correct))\r\n%%\r\nX = 123456;\r\nn=2;\r\ny_correct = 17;\r\nassert(isequal(hamming2(X,n),y_correct))","published":true,"deleted":false,"likes_count":13,"comments_count":5,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":361,"test_suite_updated_at":"2014-11-17T10:17:26.000Z","rescore_all_solutions":false,"group_id":8,"created_at":"2014-11-17T09:33:12.000Z","updated_at":"2026-02-15T13:23:19.000Z","published_at":"2014-11-17T10:14:18.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\u003eInspired by Project Euler n°204 and Problem 1308 by James\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\u003eA generalised Hamming number of type n, has no prime factor larger than 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example a generalised Hamming number of type 5 has no prime factor larger than 5.\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 a number X, determine how many generalised Hamming numbers n are less than or equal to that number. Please note that 1 counts as a Hamming number.\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":44793,"title":"Project Euler 249: Prime Subset Sums","description":"Inspired by Problem 249 of Project Euler.\r\n\u003chttps://projecteuler.net/problem=249\u003e\r\n\r\nLet S = {2, 3, 5, ...} be the set of prime numbers less than N.\r\n\r\nFind the number of subsets of S, the sum of whose elements is a prime number.\r\nEnter the rightmost 16 digits as your answer.\r\nThe answer must be a uint64 integer.","description_html":"\u003cp\u003eInspired by Problem 249 of Project Euler. \u003ca href = \"https://projecteuler.net/problem=249\"\u003ehttps://projecteuler.net/problem=249\u003c/a\u003e\u003c/p\u003e\u003cp\u003eLet S = {2, 3, 5, ...} be the set of prime numbers less than N.\u003c/p\u003e\u003cp\u003eFind the number of subsets of S, the sum of whose elements is a prime number.\r\nEnter the rightmost 16 digits as your answer.\r\nThe answer must be a uint64 integer.\u003c/p\u003e","function_template":"function num = euler249(N)\r\n  num = uint64(7) % answer for N = 10\r\nend","test_suite":"%%\r\ntic;\r\nSUM = euler249(10)\r\ntoc;\r\nassert(isequal(SUM, uint64(7)))\r\n\r\n%%\r\ntic;\r\nSUM = euler249(100)\r\ntoc;\r\nassert(isequal(SUM, uint64(5253640)))\r\n\r\n%%\r\ntic;\r\nSUM = euler249(1000)\r\ntoc;\r\nassert(isequal(SUM, uint64(5725053962252706)))\r\n%%\r\ntic;\r\nSUM = euler249(2000)\r\ntoc;\r\nassert(isequal(SUM, uint64(9536598422264105)))\r\n%%\r\ntic;\r\nSUM = euler249(4900)\r\ntoc;\r\nassert(isequal(SUM, uint64(2455225028344813)))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":8269,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-11-22T00:50:24.000Z","updated_at":"2025-12-15T21:24:15.000Z","published_at":"2018-11-22T00:50:24.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\u003eInspired by Problem 249 of Project Euler.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://projecteuler.net/problem=249\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://projecteuler.net/problem=249\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eLet S = {2, 3, 5, ...} be the set of prime numbers less than 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\u003eFind the number of subsets of S, the sum of whose elements is a prime number. Enter the rightmost 16 digits as your answer. The answer must be a uint64 integer.\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":42913,"title":"Pseudo Square Root (Inspired by Project Euler 266)","description":"Shamelessly copied from the Project Euler page for Problem 266:\r\n-------------\r\n\r\nThe divisors of 12 are: 1,2,3,4,6 and 12.\r\n\r\nThe largest divisor of 12 that does not exceed the square root of 12 is 3.\r\n\r\nWe shall call the largest divisor of an integer n that does not exceed the square root of n the pseudo square root (PSR) of n.\r\n\r\nIt can be seen that PSR(3102)=47.\r\n\r\n-------------\r\n\r\nWrite a MATLAB script that will determine what the pseudo square root of a number is.  Please note that if the number is a perfect square, the pseudo square root will equal the actual square root.","description_html":"\u003cp\u003eShamelessly copied from the Project Euler page for Problem 266:\r\n-------------\u003c/p\u003e\u003cp\u003eThe divisors of 12 are: 1,2,3,4,6 and 12.\u003c/p\u003e\u003cp\u003eThe largest divisor of 12 that does not exceed the square root of 12 is 3.\u003c/p\u003e\u003cp\u003eWe shall call the largest divisor of an integer n that does not exceed the square root of n the pseudo square root (PSR) of n.\u003c/p\u003e\u003cp\u003eIt can be seen that PSR(3102)=47.\u003c/p\u003e\u003cp\u003e-------------\u003c/p\u003e\u003cp\u003eWrite a MATLAB script that will determine what the pseudo square root of a number is.  Please note that if the number is a perfect square, the pseudo square root will equal the actual square root.\u003c/p\u003e","function_template":"function y = PSR(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 12;y_correct = 3;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx = 3102;y_correct = 47;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx=10000;y_correct = 100;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx=1308276133167003;y_correct = 36105377;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\nx=6469693230;y_correct = 79534;\r\nassert(isequal(PSR(x),y_correct))\r\n%%\r\np=cumprod(1:10);\r\ny=arrayfun(@(p) PSR(p),p);\r\ny_correct=[1 1 2 4 10 24 70 192 576 1890];\r\nassert(isequal(y,y_correct))\r\n%%\r\nx=1000000000000002;\r\nassert(isequal(PSR(PSR(x)),2))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":60,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-07-19T13:50:36.000Z","updated_at":"2026-03-16T15:35:55.000Z","published_at":"2016-07-19T13:50:36.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\u003eShamelessly copied from the Project Euler page for Problem 266: -------------\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 divisors of 12 are: 1,2,3,4,6 and 12.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe largest divisor of 12 that does not exceed the square root of 12 is 3.\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\u003eWe shall call the largest divisor of an integer n that does not exceed the square root of n the pseudo square root (PSR) of 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIt can be seen that PSR(3102)=47.\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\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\u003eWrite a MATLAB script that will determine what the pseudo square root of a number is. Please note that if the number is a perfect square, the pseudo square root will equal the actual square root.\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":1190,"title":"Golomb's self-describing sequence (based on Euler 341)","description":"The Golomb's self-describing sequence {G(n)} is the only nondecreasing sequence of natural numbers such that n appears exactly G(n) times in the sequence. The values of G(n) for the first few n are\r\n\r\n* |n =\u0026nbsp;    1    2    3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t…|\r\n* |G(n) 1    2\t2\t3\t3\t4\t4\t4\t5\t5\t\u0026nbsp;5\t\u0026nbsp;6\t\u0026nbsp;6\t\u0026nbsp;6\t\u0026nbsp;6\t\u0026nbsp;…|\r\n\r\nWrite a MATLAB script that will give you G(n) when given n.\r\n\r\nEfficiency is key here, since some of the values in the test suite will take a while to calculate.","description_html":"\u003cp\u003eThe Golomb's self-describing sequence {G(n)} is the only nondecreasing sequence of natural numbers such that n appears exactly G(n) times in the sequence. The values of G(n) for the first few n are\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ctt\u003en =\u0026nbsp;    1    2    3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t…\u003c/tt\u003e\u003c/li\u003e\u003cli\u003e\u003ctt\u003eG(n) 1    2\t2\t3\t3\t4\t4\t4\t5\t5\t\u0026nbsp;5\t\u0026nbsp;6\t\u0026nbsp;6\t\u0026nbsp;6\t\u0026nbsp;6\t\u0026nbsp;…\u003c/tt\u003e\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWrite a MATLAB script that will give you G(n) when given n.\u003c/p\u003e\u003cp\u003eEfficiency is key here, since some of the values in the test suite will take a while to calculate.\u003c/p\u003e","function_template":"function y = euler341(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(euler341(1),1))\r\n%%\r\nassert(isequal(euler341(10),5))\r\n%%\r\nassert(isequal(euler341(310),42))\r\n%%\r\nassert(isequal(euler341(4242),210))\r\n%%\r\nassert(isequal(euler341(328509),3084))\r\n%%\r\nassert(isequal(euler341(551368),4247))\r\n%%\r\nassert(isequal(euler341(614125),4540))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":183,"test_suite_updated_at":"2013-10-01T17:43:23.000Z","rescore_all_solutions":false,"group_id":27,"created_at":"2013-01-09T15:55:47.000Z","updated_at":"2026-03-25T04:50:04.000Z","published_at":"2013-01-09T15:55:47.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 Golomb's self-describing sequence {G(n)} is the only nondecreasing sequence of natural numbers such that n appears exactly G(n) times in the sequence. The values of G(n) for the first few n are\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 …\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eG(n) 1 2 2 3 3 4 4 4 5 5 5 6 6 6 6 …\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eWrite a MATLAB script that will give you G(n) when given 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\u003eEfficiency is key here, since some of the values in the test suite will take a while to calculate.\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":2721,"title":"Pandigital Factors (Based on Euler 491)","description":"A Pandigital Number is a number containing all of the digits from 0-9 inclusive, with the added stipulation that it does not have a leading zero.  Lower level pandigital numbers just contain the digits 0-X, where X is less than 9.\r\n\r\nWrite a MATLAB script that takes as input the number X, and another integer Y.  Determine how many pandigital numbers containing the digits 0-X are evenly divisible by Y.  For example, there are thirteen pandigital numbers containing 0-4 that are evenly divisible by 7:\r\n\r\n       43120\r\n       42301\r\n       41230\r\n       32410\r\n       31402\r\n       31024\r\n       30142\r\n       23401\r\n       24031\r\n       20314\r\n       14203\r\n       10234\r\n       10423\r\n\r\nThe number 03421 does not count.  Even though it contains all of the digits 0-4, it has a leading zero.  Therefore, the output of pandigit_factors(4,7) would be 13.  You do not need to output all of the numbers themselves, just how many of them there are.  Good luck!","description_html":"\u003cp\u003eA Pandigital Number is a number containing all of the digits from 0-9 inclusive, with the added stipulation that it does not have a leading zero.  Lower level pandigital numbers just contain the digits 0-X, where X is less than 9.\u003c/p\u003e\u003cp\u003eWrite a MATLAB script that takes as input the number X, and another integer Y.  Determine how many pandigital numbers containing the digits 0-X are evenly divisible by Y.  For example, there are thirteen pandigital numbers containing 0-4 that are evenly divisible by 7:\u003c/p\u003e\u003cpre\u003e       43120\r\n       42301\r\n       41230\r\n       32410\r\n       31402\r\n       31024\r\n       30142\r\n       23401\r\n       24031\r\n       20314\r\n       14203\r\n       10234\r\n       10423\u003c/pre\u003e\u003cp\u003eThe number 03421 does not count.  Even though it contains all of the digits 0-4, it has a leading zero.  Therefore, the output of pandigit_factors(4,7) would be 13.  You do not need to output all of the numbers themselves, just how many of them there are.  Good luck!\u003c/p\u003e","function_template":"function pf = pandigit_factors(x,y)\r\n  pf=x*y;\r\nend","test_suite":"%%\r\nx = 4;y=7;\r\ny_correct = 13;\r\nassert(isequal(pandigit_factors(x,y),y_correct));\r\n%%\r\nx = 3;y=3;\r\ny_correct = 18;\r\nassert(isequal(pandigit_factors(x,y),y_correct));\r\n%%\r\nx = 8;y=8;\r\ny_correct = 45360;\r\nassert(isequal(pandigit_factors(x,y),y_correct));\r\n%%\r\nj=[600 312 600 144 216 312 75 74 0 120 0 144 55];\r\nx=5;y=ceil(13*rand)\r\nassert(isequal(pandigit_factors(x,y),j(y)));\r\n%%\r\nx=1;y=10;\r\nassert(isequal(pandigit_factors(x,y),x));","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":41,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-05T17:20:24.000Z","updated_at":"2025-11-30T01:34:22.000Z","published_at":"2014-12-05T17:20:24.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\u003eA Pandigital Number is a number containing all of the digits from 0-9 inclusive, with the added stipulation that it does not have a leading zero. Lower level pandigital numbers just contain the digits 0-X, where X is less than 9.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eWrite a MATLAB script that takes as input the number X, and another integer Y. Determine how many pandigital numbers containing the digits 0-X are evenly divisible by Y. For example, there are thirteen pandigital numbers containing 0-4 that are evenly divisible by 7:\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[       43120\\n       42301\\n       41230\\n       32410\\n       31402\\n       31024\\n       30142\\n       23401\\n       24031\\n       20314\\n       14203\\n       10234\\n       10423]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe number 03421 does not count. Even though it contains all of the digits 0-4, it has a leading zero. Therefore, the output of pandigit_factors(4,7) would be 13. You do not need to output all of the numbers themselves, just how many of them there are. Good luck!\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":44316,"title":"Pandigital Multiples of 11 (based on Project Euler 491)","description":"A \"Pandigital number of order X\" is one that contains all of the numbers from 0 to X, but with no leading zeroes. If X\u003e9, the cycle 0-9 repeats itself. For example, 2310 is a Pandigital number of order 3 (0-3), while 120345678901 is a Pandigital number of order 11, with the \"01\" at the end of the number representing 10 and 11, respectively (10 and 11 mod 10, essentially). 0321 is not a Pandigital number, as it has a leading zero.\r\n\r\nGiven a number X, determine how many pandigital numbers of that order are divisible by 11.  You do not need to return the numbers themselves, just how many of them there are.","description_html":"\u003cp\u003eA \"Pandigital number of order X\" is one that contains all of the numbers from 0 to X, but with no leading zeroes. If X\u0026gt;9, the cycle 0-9 repeats itself. For example, 2310 is a Pandigital number of order 3 (0-3), while 120345678901 is a Pandigital number of order 11, with the \"01\" at the end of the number representing 10 and 11, respectively (10 and 11 mod 10, essentially). 0321 is not a Pandigital number, as it has a leading zero.\u003c/p\u003e\u003cp\u003eGiven a number X, determine how many pandigital numbers of that order are divisible by 11.  You do not need to return the numbers themselves, just how many of them there are.\u003c/p\u003e","function_template":"function y = pandigitalby11(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2;y_correct = 0;\r\nassert(isequal(pandigitalby11(x),y_correct))\r\n%%\r\nx = 3;y_correct = 6;\r\nassert(isequal(pandigitalby11(x),y_correct))\r\n%%\r\nx = 7;y_correct = 4032;\r\nassert(isequal(pandigitalby11(x),y_correct))\r\n%%\r\np6=pandigitalby11(6);\r\np8=pandigitalby11(8);\r\np9=pandigitalby11(9);\r\n\r\nassert(p8\u003ep6);\r\nassert(p9\u003ep8);\r\n\r\nf6=factor(p6);\r\nf8=factor(p8);\r\nf9=factor(p9);\r\nf9e1=f9(end-1);\r\n\r\nassert(p6\u003e256);\r\nassert(max(f9)\u003cmax(f8));\r\nassert(f9e1\u003emax(f6));\r\nassert(numel(f9)\u003enumel(f8));\r\n%%\r\nx = 11;y_correct = 9072000;\r\nassert(isequal(pandigitalby11(x),y_correct))\r\n%%\r\nx = 14;y_correct = 3216477600;\r\nassert(isequal(pandigitalby11(x),y_correct))\r\n%%\r\nassert(isequal(pandigitalby11(16),222911740800))","published":true,"deleted":false,"likes_count":5,"comments_count":15,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2017-10-23T01:32:05.000Z","rescore_all_solutions":false,"group_id":35,"created_at":"2017-09-12T15:26:05.000Z","updated_at":"2026-02-03T09:29:47.000Z","published_at":"2017-10-16T01:50:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA \\\"Pandigital number of order X\\\" is one that contains all of the numbers from 0 to X, but with no leading zeroes. If X\u0026gt;9, the cycle 0-9 repeats itself. For example, 2310 is a Pandigital number of order 3 (0-3), while 120345678901 is a Pandigital number of order 11, with the \\\"01\\\" at the end of the number representing 10 and 11, respectively (10 and 11 mod 10, essentially). 0321 is not a Pandigital number, as it has a leading zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a number X, determine how many pandigital numbers of that order are divisible by 11. You do not need to return the numbers themselves, just how many of them there are.\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":42394,"title":"It's going down.  We're finding simbers!","description":"This problem is inspired by Project Euler 520: Simbers.\r\n\r\n\"We define a simber to be a positive integer in which any odd digit, if present, occurs an odd number of times, and any even digit, if present, occurs an even number of times.\r\n\r\nFor example, 141221242 is a 9-digit simber because it has three 1's, four 2's and two 4's.\"\r\n\r\nGiven a number, determine if it a simber or not.  Please note that the number will be in *string* format as some of the entries may be quite long.  You can assume there will be no leading zeroes in any of the numbers.\r\n","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; transform-origin: 332px 87px; vertical-align: baseline; perspective-origin: 332px 87px; \"\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThis problem is inspired by Project Euler 520: Simbers.\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; transform-origin: 309px 21px; white-space: pre-wrap; perspective-origin: 309px 21px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\"We define a simber to be a positive integer in which any odd digit, if present, occurs an odd number of times, and any even digit, if present, occurs an even number of times.\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, 141221242 is a 9-digit simber because it has three 1's, four 2's and two 4's.\"\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; transform-origin: 309px 31.5px; white-space: pre-wrap; perspective-origin: 309px 31.5px; 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; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eGiven a number, determine if it a simber or not. Please note that the number will be in\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: bold; \"\u003estring\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e format as some of the entries may be quite long. You can assume there will be no leading zeroes in any of the numbers.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = simber(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nassert(isequal(simber('141221242'),true))\r\n%%\r\nassert(isequal(simber('1223334444'),true))\r\n%%\r\nassert(isequal(simber('122333444'),false))\r\n%%\r\nassert(isequal(simber('567886'),true))\r\n%%\r\nassert(isequal(simber('999999999888888888'),false))\r\n%%\r\nassert(isequal(simber('6677788'),true))\r\n%%\r\nv=arrayfun(@(x) simber(num2str(x)),1:100);\r\ny_correct=[1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 1];\r\nassert(isequal(v,y_correct))\r\n%%\r\nk=arrayfun(@(x) simber(sprintf('%.0f',2^x+1)),1:39);\r\ny_correct=[1 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];\r\nassert(isequal(k,y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":87,"test_suite_updated_at":"2020-09-29T03:05:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-06-18T19:55:17.000Z","updated_at":"2026-03-16T15:14:55.000Z","published_at":"2015-06-18T19:55:17.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is inspired by Project Euler 520: Simbers.\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\\\"We define a simber to be a positive integer in which any odd digit, if present, occurs an odd number of times, and any even digit, if present, occurs an even number of times.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, 141221242 is a 9-digit simber because it has three 1's, four 2's and two 4's.\\\"\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 a number, determine if it a simber or not. Please note that the number will be 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:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estring\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e format as some of the entries may be quite long. You can assume there will be no leading zeroes in any of the numbers.\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":42754,"title":"Odd elimination","description":"Inspired by Project Euler problem #539\r\n\r\nYou'll be given a vector from 1 to n; \r\n\r\nGoing from left to right, remove the first number and every other number afterward until the end of the list. \r\n\r\nRepeat the procedure from right to left, removing the right most number and every other number from the numbers left. Continue removing every other numbers, alternating left to right and right to left, until a single number remains.\r\n\r\nExample with n=9 \r\n\r\n1 2 3 4 5 6 7 8 9\r\n\r\n2 4 6 8\r\n\r\n2 6\r\n\r\n6\r\n\r\n\r\n","description_html":"\u003cp\u003eInspired by Project Euler problem #539\u003c/p\u003e\u003cp\u003eYou'll be given a vector from 1 to n;\u003c/p\u003e\u003cp\u003eGoing from left to right, remove the first number and every other number afterward until the end of the list.\u003c/p\u003e\u003cp\u003eRepeat the procedure from right to left, removing the right most number and every other number from the numbers left. Continue removing every other numbers, alternating left to right and right to left, until a single number remains.\u003c/p\u003e\u003cp\u003eExample with n=9\u003c/p\u003e\u003cp\u003e1 2 3 4 5 6 7 8 9\u003c/p\u003e\u003cp\u003e2 4 6 8\u003c/p\u003e\u003cp\u003e2 6\u003c/p\u003e\u003cp\u003e6\u003c/p\u003e","function_template":"function y = odd_elimination(n)\r\n  y=;\r\nend","test_suite":"%%\r\nn = 9;\r\ny_correct = 6;\r\nassert(isequal(odd_elimination(n),y_correct))\r\n\r\n%%\r\nn = 1000;\r\ny_correct = 510;\r\nassert(isequal(odd_elimination(n),y_correct))\r\n\r\n%%\r\nn = 99;\r\ny_correct = 56;\r\nassert(isequal(odd_elimination(n),y_correct))\r\n\r\n%%\r\nn = 5000;\r\ny_correct = 2014;\r\nassert(isequal(odd_elimination(n),y_correct))\r\n\r\n%%\r\nn = 100000;\r\ny_correct = 55286;\r\nassert(isequal(odd_elimination(n),y_correct))\r\n\r\n\r\n%%\r\nn = 666;\r\ny_correct = 480;\r\nassert(isequal(odd_elimination(n),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":17228,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":67,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-02-25T09:19:38.000Z","updated_at":"2025-12-07T20:45:00.000Z","published_at":"2016-02-25T09:20:10.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\u003eInspired by Project Euler problem #539\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\u003eYou'll be given a vector from 1 to 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGoing from left to right, remove the first number and every other number afterward until the end of the list.\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\u003eRepeat the procedure from right to left, removing the right most number and every other number from the numbers left. Continue removing every other numbers, alternating left to right and right to left, until a single number remains.\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\u003eExample with n=9\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\u003e1 2 3 4 5 6 7 8 9\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\u003e2 4 6 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2 6\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\u003e6\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":1092,"title":"Decimation","description":"When dealing to the Roman Army, the term decimate meant that the entire unit would be broken up into groups of ten soldiers, and lots would be drawn.  The person who was unlucky enough to draw the short straw would be executed by the other nine members of his group.\r\n\r\nThe bloodthirsty Roman Centurion Carnage Maximus decided to apply this to his prisoners, with a few gruesome differences.  Rather than kill every tenth prisoner and allow the rest to live, he is going to leave only one prisoner alive and kill all of the others.  Instead of killing every tenth prisoner, he chooses a number (kill_every).  If kill_every=3, he kills every third prisoner.  If kill_every=5, he kills every fifth prisoner.  He always chooses a number between 2 and the number of prisoners he has, and this process will be repeated until there is only one prisoner left.  For example, if there are 10 prisoners, and kill_every=3\r\n\r\nFirst iteration: 1 2 3 4 5 6 7 8 9 10\r\n\r\n1-2-3 4-5-6 7-8-9 10\r\n\r\nPrisoners 3, 6 and 9 will be killed.\r\n\r\nSecond iteration: 1 2 4 5 7 8 10\r\n\r\nBecause Prisoner 10 was counted during the first iteration, the executions\r\nwill proceed as such: 10-1-2 4-5-7 8-10, so prisoners 2 and 7 will be killed\r\n\r\nThird iteration: 1 4 5 8 10\r\n8-10-1 4-5-8 10, so prisoners 1 and 8 executed.\r\n\r\nFourth Iteration:  10-4-5 10\r\nPrisoner 5 is executed.\r\n\r\nFifth iteration:  10-4 10\r\nPrisoner 10 is executed\r\n\r\nSince the sole survivor is prisoner 4, he is released.\r\n\r\nYou are an unlucky prisoner caught by Carnage Maximum.  Prior to lining up the prisoners, he reveals the number of prisoners he has and his value of kill_every for the day.  Your job is to figure out which prisoner you need to be in order to survive.  Write a MATLAB script that takes the values of num_prisoners and kill_every.  The output will be survivor, which is the position of the person who survives.  If you write your script quickly enough, that person will be you.\r\n\r\nGood luck!","description_html":"\u003cp\u003eWhen dealing to the Roman Army, the term decimate meant that the entire unit would be broken up into groups of ten soldiers, and lots would be drawn.  The person who was unlucky enough to draw the short straw would be executed by the other nine members of his group.\u003c/p\u003e\u003cp\u003eThe bloodthirsty Roman Centurion Carnage Maximus decided to apply this to his prisoners, with a few gruesome differences.  Rather than kill every tenth prisoner and allow the rest to live, he is going to leave only one prisoner alive and kill all of the others.  Instead of killing every tenth prisoner, he chooses a number (kill_every).  If kill_every=3, he kills every third prisoner.  If kill_every=5, he kills every fifth prisoner.  He always chooses a number between 2 and the number of prisoners he has, and this process will be repeated until there is only one prisoner left.  For example, if there are 10 prisoners, and kill_every=3\u003c/p\u003e\u003cp\u003eFirst iteration: 1 2 3 4 5 6 7 8 9 10\u003c/p\u003e\u003cp\u003e1-2-3 4-5-6 7-8-9 10\u003c/p\u003e\u003cp\u003ePrisoners 3, 6 and 9 will be killed.\u003c/p\u003e\u003cp\u003eSecond iteration: 1 2 4 5 7 8 10\u003c/p\u003e\u003cp\u003eBecause Prisoner 10 was counted during the first iteration, the executions\r\nwill proceed as such: 10-1-2 4-5-7 8-10, so prisoners 2 and 7 will be killed\u003c/p\u003e\u003cp\u003eThird iteration: 1 4 5 8 10\r\n8-10-1 4-5-8 10, so prisoners 1 and 8 executed.\u003c/p\u003e\u003cp\u003eFourth Iteration:  10-4-5 10\r\nPrisoner 5 is executed.\u003c/p\u003e\u003cp\u003eFifth iteration:  10-4 10\r\nPrisoner 10 is executed\u003c/p\u003e\u003cp\u003eSince the sole survivor is prisoner 4, he is released.\u003c/p\u003e\u003cp\u003eYou are an unlucky prisoner caught by Carnage Maximum.  Prior to lining up the prisoners, he reveals the number of prisoners he has and his value of kill_every for the day.  Your job is to figure out which prisoner you need to be in order to survive.  Write a MATLAB script that takes the values of num_prisoners and kill_every.  The output will be survivor, which is the position of the person who survives.  If you write your script quickly enough, that person will be you.\u003c/p\u003e\u003cp\u003eGood luck!\u003c/p\u003e","function_template":"function survivor=decimate(num_prisoners,kill_every)\r\nsurvivor=4;\r\nend","test_suite":"%%\r\nassert(isequal(decimate(10,3),4))\r\n%%\r\nassert(isequal(decimate(1024,3),676))\r\n%%\r\nassert(isequal(decimate(2012,50),543))\r\n%%\r\nassert(isequal(decimate(30,5),3))\r\n%%\r\nassert(isequal(decimate(10,10),8))\r\n%%\r\nassert(isequal(decimate(2048,2),1))","published":true,"deleted":false,"likes_count":20,"comments_count":12,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":310,"test_suite_updated_at":"2012-12-04T21:28:04.000Z","rescore_all_solutions":false,"group_id":13,"created_at":"2012-12-04T19:47:49.000Z","updated_at":"2026-03-18T19:18:48.000Z","published_at":"2012-12-04T19:53:55.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\u003eWhen dealing to the Roman Army, the term decimate meant that the entire unit would be broken up into groups of ten soldiers, and lots would be drawn. The person who was unlucky enough to draw the short straw would be executed by the other nine members of his group.\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 bloodthirsty Roman Centurion Carnage Maximus decided to apply this to his prisoners, with a few gruesome differences. Rather than kill every tenth prisoner and allow the rest to live, he is going to leave only one prisoner alive and kill all of the others. Instead of killing every tenth prisoner, he chooses a number (kill_every). If kill_every=3, he kills every third prisoner. If kill_every=5, he kills every fifth prisoner. He always chooses a number between 2 and the number of prisoners he has, and this process will be repeated until there is only one prisoner left. For example, if there are 10 prisoners, and kill_every=3\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\u003eFirst iteration: 1 2 3 4 5 6 7 8 9 10\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\u003e1-2-3 4-5-6 7-8-9 10\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\u003ePrisoners 3, 6 and 9 will be killed.\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\u003eSecond iteration: 1 2 4 5 7 8 10\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\u003eBecause Prisoner 10 was counted during the first iteration, the executions will proceed as such: 10-1-2 4-5-7 8-10, so prisoners 2 and 7 will be killed\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\u003eThird iteration: 1 4 5 8 10 8-10-1 4-5-8 10, so prisoners 1 and 8 executed.\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\u003eFourth Iteration: 10-4-5 10 Prisoner 5 is executed.\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\u003eFifth iteration: 10-4 10 Prisoner 10 is executed\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\u003eSince the sole survivor is prisoner 4, he is released.\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\u003eYou are an unlucky prisoner caught by Carnage Maximum. Prior to lining up the prisoners, he reveals the number of prisoners he has and his value of kill_every for the day. Your job is to figure out which prisoner you need to be in order to survive. Write a MATLAB script that takes the values of num_prisoners and kill_every. The output will be survivor, which is the position of the person who survives. If you write your script quickly enough, that person will be you.\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\u003eGood luck!\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":44668,"title":"Day counter function","description":"Write a function called day_counter that returns the number of Mondays that fell on the first day of the month in a given year between 1776 and 2016 inclusive where the requested year is the only input to your function and it is a positive integer scalar. Note that a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. In a leap year, February has 29 days.\r\nYou are not allowed to use the datenum built-in function.\r\n(Inspired by Project Euler.)","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: 144px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 72px; transform-origin: 407px 72px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 70px 8px; transform-origin: 70px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function called\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 39.5px 8px; transform-origin: 39.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eday_counter\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 265px 8px; transform-origin: 265px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that returns the number of Mondays that fell on the first day of the month in a given year between 1776 and 2016 inclusive where the requested year is the only input to your function and it is a positive integer scalar. Note that a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. In a leap year, February has 29 days.\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: 199px 8px; transform-origin: 199px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eYou are not allowed to use the datenum built-in function.\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: 93px 8px; transform-origin: 93px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e(Inspired by Project Euler.)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"% function to count number of mondays\r\nfunction foms = day_counter( year )\r\n\r\nend","test_suite":"%%\r\nyear  = 1902;\r\nfoms_correct = 2;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 2002;\r\nfoms_correct = 2;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 1996;\r\nfoms_correct = 3;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 1885;\r\nfoms_correct = 1;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 2000;\r\nfoms_correct = 1;\r\nassert(isequal(day_counter( year ),foms_correct))\r\n\r\n%%\r\nyear  = 2013;\r\nfoms_correct = 2;\r\nassert(isequal(day_counter( year ),foms_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":223089,"edited_at":"2023-01-16T11:22:13.000Z","deleted_by":null,"deleted_at":null,"solvers_count":77,"test_suite_updated_at":"2023-01-16T11:22:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-30T02:42:41.000Z","updated_at":"2026-01-01T20:23:31.000Z","published_at":"2018-05-30T02:42:41.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\u003eWrite a function called\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\u003eday_counter\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that returns the number of Mondays that fell on the first day of the month in a given year between 1776 and 2016 inclusive where the requested year is the only input to your function and it is a positive integer scalar. Note that a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. In a leap year, February has 29 days.\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eYou are not allowed to use the datenum built-in function.\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e(Inspired by Project Euler.)\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\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}