{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":43614,"title":"Convert binary numbers array into array of decimal numbers.","description":"Convert binary numbers array into array of decimal numbers.\r\nExample\r\nx=[ 11001000 ; 11001001 ; 11001010 ; 11001011 ; 11001100 ; 11001101 ; 11001110 ; 11001111 ; 11010000 ; 11010001 ; 11010010 ; 11010011 ; 11010100 ; 11010101 ; 11010110 ; 11010111 ; 11011000 ; 11011001 ; 11011010 ; 11011011 ; 11011100 ; 11011101 ; 11011110 ; 11011111 ; 11100000 ; 11100001 ; 11100010 ; 11100011 ; 11100100 ; 11100101 ; 11100110]\r\nres= [ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230]","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: 195px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97.5px; transform-origin: 407px 97.5px; 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: 192px 8px; transform-origin: 192px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eConvert binary numbers array into array of decimal numbers.\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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 382px 8px; transform-origin: 382px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ex=[ 11001000 ; 11001001 ; 11001010 ; 11001011 ; 11001100 ; 11001101 ; 11001110 ; 11001111 ; 11010000 ; 11010001 ; 11010010 ; 11010011 ; 11010100 ; 11010101 ; 11010110 ; 11010111 ; 11011000 ; 11011001 ; 11011010 ; 11011011 ; 11011100 ; 11011101 ; 11011110 ; 11011111 ; 11100000 ; 11100001 ; 11100010 ; 11100011 ; 11100100 ; 11100101 ; 11100110]\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: 375.5px 8px; transform-origin: 375.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eres= [ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = BinToDec(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx=[ \r\n11001000 ;\r\n11001001 ; \r\n11001010 ;\r\n11001011 ;\r\n11001100 ;\r\n11001101 ;\r\n11001110 ;\r\n11001111 ;\r\n11010000 ;\r\n11010001 ;\r\n11010010 ;\r\n11010011 ;\r\n11010100 ;\r\n11010101 ;\r\n11010110 ;\r\n11010111 ; \r\n11011000 ; \r\n11011001 ;\r\n11011010 ; \r\n11011011 ;\r\n11011100 ;\r\n11011101 ; \r\n11011110 ;\r\n11011111 ;\r\n11100000 ; \r\n11100001 ;\r\n11100010 ;\r\n11100011 ;\r\n11100100 ;\r\n11100101 ;\r\n11100110 ];\r\ny_correct =[ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 ; 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230];\r\nassert(isequal(BinToDec(x),y_correct))\r\n%%\r\nx= [ \r\n101000000;\r\n101000001;\r\n101000010;\r\n101000011;\r\n101000100;\r\n101000101;\r\n101000110;\r\n101000111;\r\n101001000;\r\n101001001;\r\n101001010;\r\n101001011;\r\n101001100;\r\n101001101;\r\n101001110;\r\n101001111;\r\n101010000;\r\n101010001;\r\n101010010;\r\n101010011;\r\n101010100 ];\r\ny_correct =[ 320  ; 321  ; 322  ; 323  ; 324  ; 325  ; 326 ;  327  ; 328  ; 329  ; 330 ;  331 ;  332  ; 333  ; 334  ; 335  ; 336 ;  337 ;  338  ; 339  ; 340 ];\r\nassert(isequal(BinToDec(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":90467,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":170,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T21:26:58.000Z","updated_at":"2026-03-31T17:53:25.000Z","published_at":"2016-10-24T21:27:38.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\u003eConvert binary numbers array into array of decimal numbers.\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\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\u003ex=[ 11001000 ; 11001001 ; 11001010 ; 11001011 ; 11001100 ; 11001101 ; 11001110 ; 11001111 ; 11010000 ; 11010001 ; 11010010 ; 11010011 ; 11010100 ; 11010101 ; 11010110 ; 11010111 ; 11011000 ; 11011001 ; 11011010 ; 11011011 ; 11011100 ; 11011101 ; 11011110 ; 11011111 ; 11100000 ; 11100001 ; 11100010 ; 11100011 ; 11100100 ; 11100101 ; 11100110]\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\u003eres= [ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230]\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":1338,"title":"Binary Coder","description":"Take an input number and print the binary value of this number.","description_html":"\u003cp\u003eTake an input number and print the binary value of this number.\u003c/p\u003e","function_template":"function y = binary_coder(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 8;\r\ny_correct = 1000;\r\nassert(isequal(binary_coder(x),y_correct))\r\n\r\n%%\r\nx = 24;\r\ny_correct = 11000;\r\nassert(isequal(binary_coder(x),y_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":11534,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":273,"test_suite_updated_at":"2013-03-10T18:56:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-03-10T18:19:00.000Z","updated_at":"2026-03-27T18:21:15.000Z","published_at":"2013-03-10T18:19:00.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\u003eTake an input number and print the binary value of this 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":1861,"title":"Binary","description":"Given a positive, integer n, create a function that returns the respective binary number in the form of a vector.\r\n\r\nExample:\r\n\r\n   input: 3\r\n  output: [1 1]","description_html":"\u003cp\u003eGiven a positive, integer n, create a function that returns the respective binary number in the form of a vector.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e   input: 3\r\n  output: [1 1]\u003c/pre\u003e","function_template":"function y = binary(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = [1];\r\nassert(isequal(binary(n),y_correct))\r\n\r\n%%\r\nn = 7;\r\ny_correct = [1 1 1];\r\nassert(isequal(binary(n),y_correct))\r\n\r\n%%\r\nn = 10;\r\ny_correct = [1 0 1 0];\r\nassert(isequal(binary(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":17224,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":224,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-06T15:49:18.000Z","updated_at":"2026-04-01T12:54:33.000Z","published_at":"2013-09-06T15:49:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive, integer n, create a function that returns the respective binary number in the form of a vector.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   input: 3\\n  output: [1 1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":43977,"title":"Converting binary to decimals","description":"Convert binary to decimals.\r\n\r\nExample:\r\n\r\n010111 = 23. \r\n\r\n110000 = 48.","description_html":"\u003cp\u003eConvert binary to decimals.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003e010111 = 23.\u003c/p\u003e\u003cp\u003e110000 = 48.\u003c/p\u003e","function_template":"function y = bin_to_dec(d)\r\n  y = d;\r\nend","test_suite":"%%\r\nd = ('010111');\r\ny_correct = 23;\r\nassert(isequal(bin_to_dec(d),y_correct))\r\n\r\n%%\r\nd = ('110000');\r\ny_correct = 48;\r\nassert(isequal(bin_to_dec(d),y_correct))\r\n\r\n%%\r\nd = ('1000110');\r\ny_correct = 70;\r\nassert(isequal(bin_to_dec(d),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":108624,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1701,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-29T13:49:15.000Z","updated_at":"2026-04-01T08:57:55.000Z","published_at":"2016-12-29T13:51:20.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConvert binary to decimals.\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:\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\u003e010111 = 23.\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\u003e110000 = 48.\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":2202,"title":"Flip the bit","description":"Given an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').","description_html":"\u003cp\u003eGiven an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').\u003c/p\u003e","function_template":"function y = flipbit(s)\r\n  y = '010101';\r\nend","test_suite":"%%\r\ns = '1001';\r\ny_correct = '0110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '11';\r\ny_correct = '00';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '1';\r\ny_correct = '0';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '100000001';\r\ny_correct = '011111110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '00001';\r\ny_correct = '11110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":2,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":535,"test_suite_updated_at":"2014-02-20T18:44:05.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-02-20T15:53:55.000Z","updated_at":"2026-03-19T20:08:33.000Z","published_at":"2014-02-20T15:56:43.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').\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":2522,"title":"Convert given decimal number to binary number. ","description":"Convert given decimal number to binary number.\r\nExample x=10, then answer must be 1010.","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: 51px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 25.5px; transform-origin: 407px 25.5px; 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: 153px 8px; transform-origin: 153px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eConvert given decimal number to binary number.\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: 133px 8px; transform-origin: 133px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample x=10, then answer must be 1010.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = dec_bin(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 0;\r\nassert(isequal(dec_bin(x),x))\r\n%%\r\nx = 10;\r\ny_correct = 1010;\r\nassert(isequal(dec_bin(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct =  10;\r\nassert(isequal(dec_bin(x),y_correct))\r\n%%\r\nx = 15;\r\ny_correct =  1111;\r\nassert(isequal(dec_bin(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct =  101;\r\nassert(isequal(dec_bin(x),y_correct))","published":true,"deleted":false,"likes_count":20,"comments_count":4,"created_by":27760,"edited_by":223089,"edited_at":"2022-05-02T16:13:29.000Z","deleted_by":null,"deleted_at":null,"solvers_count":2284,"test_suite_updated_at":"2022-05-02T16:13:29.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-20T07:56:26.000Z","updated_at":"2026-04-03T02:25:05.000Z","published_at":"2014-08-20T07:56:26.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\u003eConvert given decimal number to binary number.\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 x=10, then answer must be 1010.\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":1547,"title":"Relative ratio of \"1\" in binary number","description":"Input(n) is positive integer number\r\n\r\nOutput(r) is (number of \"1\" in binary input) / (number of bits).\r\n\r\nExample:\r\n\r\n* n=0; r=0\r\n* n=1; r=1\r\n* n=2; r=0.5\r\n","description_html":"\u003cp\u003eInput(n) is positive integer number\u003c/p\u003e\u003cp\u003eOutput(r) is (number of \"1\" in binary input) / (number of bits).\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cul\u003e\u003cli\u003en=0; r=0\u003c/li\u003e\u003cli\u003en=1; r=1\u003c/li\u003e\u003cli\u003en=2; r=0.5\u003c/li\u003e\u003c/ul\u003e","function_template":"function r = ones_ratio(n)\r\n  r = n;\r\nend","test_suite":"%%\r\nx = 0;\r\ny_correct = 0;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 0.5;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = 1;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 128;\r\ny_correct = 0.125;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 1265476542;\r\ny_correct = 19/31;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 98917653181;\r\ny_correct = 23/37;\r\nassert(isequal(ones_ratio(x),y_correct))","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":14249,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1599,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-06-04T23:29:28.000Z","updated_at":"2026-04-01T08:15:52.000Z","published_at":"2013-06-04T23:29:28.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\u003eInput(n) is positive integer number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput(r) is (number of \\\"1\\\" in binary input) / (number of bits).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=0; r=0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=1; r=1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=2; r=0.5\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":2891,"title":"Binary code (array)","description":"Write a function which calculates the binary code of a number 'n' and gives the result as an array(vector).\r\n\r\nExample:\r\n\r\n Input  n = 123\r\n Output y =[1,1,1,1,0,1,1]\r\n\r\n","description_html":"\u003cp\u003eWrite a function which calculates the binary code of a number 'n' and gives the result as an array(vector).\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input  n = 123\r\n Output y =[1,1,1,1,0,1,1]\u003c/pre\u003e","function_template":"function y = dectobin(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2015;\r\ny_correct=[1,1,1,1,1,0,1,1,1,1,1];\r\nassert(isequal(dectobin(x),y_correct))\r\n%%\r\nx = 13;\r\ny_correct=[1,1,0,1];\r\nassert(isequal(dectobin(x),y_correct))\r\n%%\r\nx = 143;\r\ny_correct=[1,0,0,0,1,1,1,1];\r\nassert(isequal(dectobin(x),y_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":33976,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1546,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-01-28T15:49:50.000Z","updated_at":"2026-04-01T08:50:33.000Z","published_at":"2015-01-28T15:54:03.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\u003eWrite a function which calculates the binary code of a number 'n' and gives the result as an array(vector).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  n = 123\\n Output y =[1,1,1,1,0,1,1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":568,"title":"Number of 1s in a binary string","description":"Find the number of 1s in the given binary string.\r\nExample. If the input string is '1100101', the output is 4. If the input string is '0000', the output is 0","description_html":"\u003cp\u003eFind the number of 1s in the given binary string.\r\nExample. If the input string is '1100101', the output is 4. If the input string is '0000', the output is 0\u003c/p\u003e","function_template":"function y = one(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = '0000';\r\ny_correct = 0;\r\nassert(isequal(one(x),y_correct));\r\n\r\n%%\r\nx = '111';\r\ny_correct = 3;\r\nassert(isequal(one(x),y_correct));\r\n\r\n%%\r\nx = '1100101';\r\ny_correct = 4;\r\nassert(isequal(one(x),y_correct));\r\n","published":true,"deleted":false,"likes_count":63,"comments_count":3,"created_by":2974,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11055,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":14,"created_at":"2012-04-10T19:15:07.000Z","updated_at":"2026-04-03T02:22:17.000Z","published_at":"2012-04-10T19:15:11.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\u003eFind the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input string is '0000', the output is 0\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":2678,"title":"Find out sum and carry of Binary adder","description":"Find out sum and carry of a binary adder if previous carry is given with two bits (x and y) for addition. \r\n\r\nExamples\r\n\r\nPrevious carry is 1 and  x=y=1. Addition is 1 and carry is also 1. \r\n\r\nPrevious carry is 0 and  x=y=1. Addition is 0 and carry is also 1. \r\n\r\nPrevious carry is 0 and  x=1, y=0. Addition is 1 and carry is also 0. ","description_html":"\u003cp\u003eFind out sum and carry of a binary adder if previous carry is given with two bits (x and y) for addition.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cp\u003ePrevious carry is 1 and  x=y=1. Addition is 1 and carry is also 1.\u003c/p\u003e\u003cp\u003ePrevious carry is 0 and  x=y=1. Addition is 0 and carry is also 1.\u003c/p\u003e\u003cp\u003ePrevious carry is 0 and  x=1, y=0. Addition is 1 and carry is also 0.\u003c/p\u003e","function_template":"function [sum, carry] = bin_sum_carry(pc,x,y)\r\n  \r\nend","test_suite":"%%\r\nx = 1;\r\ny=1;\r\npc=1;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,1))\r\nassert(isequal(carry,1))\r\n%%\r\nx = 1;\r\ny=1;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,0))\r\nassert(isequal(carry,1))\r\n%%\r\nx = 1;\r\ny=0;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,1))\r\nassert(isequal(carry,0))\r\n%%\r\nx = 0;\r\ny=0;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,0))\r\nassert(isequal(carry,0))\r\n%%\r\nx = 1;\r\ny=1;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,0))\r\nassert(isequal(carry,1))\r\n","published":true,"deleted":false,"likes_count":12,"comments_count":3,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1704,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-11-18T04:58:05.000Z","updated_at":"2026-04-03T20:51:13.000Z","published_at":"2014-11-18T04:58:05.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\u003eFind out sum and carry of a binary adder if previous carry is given with two bits (x and y) for addition.\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\u003eExamples\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\u003ePrevious carry is 1 and x=y=1. Addition is 1 and carry is also 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious carry is 0 and x=y=1. Addition is 0 and carry is also 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious carry is 0 and x=1, y=0. Addition is 1 and carry is also 0.\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":1295,"title":"Bit Reversal","description":"Given an unsigned integer _x_, convert it to binary with _n_ bits, reverse the order of the bits, and convert it back to an integer.","description_html":"\u003cp\u003eGiven an unsigned integer \u003ci\u003ex\u003c/i\u003e, convert it to binary with \u003ci\u003en\u003c/i\u003e bits, reverse the order of the bits, and convert it back to an integer.\u003c/p\u003e","function_template":"function y = bit_reverse(x,n)\r\n  y = 2^n-x;\r\nend","test_suite":"%%\r\nassert(bit_reverse(1,1) == 1)\r\n\r\n%%\r\nassert(bit_reverse(4,3) == 1)\r\n\r\n%%\r\nassert(bit_reverse(2,3) == 2)\r\n\r\n%%\r\nassert(bit_reverse(6,3) == 3)\r\n\r\n%%\r\nassert(bit_reverse(5,3) == 5)\r\n\r\n%%\r\nassert(bit_reverse(7,3) == 7)","published":true,"deleted":false,"likes_count":13,"comments_count":0,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1618,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-02-22T23:16:57.000Z","updated_at":"2026-03-31T11:00:54.000Z","published_at":"2013-02-22T23:16:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an unsigned integer\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\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, convert it to binary with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e bits, reverse the order of the bits, and convert it back to an 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":108,"title":"Given an unsigned integer x, find the largest y by rearranging the bits in x","description":"Given an unsigned integer x, find the largest y by rearranging the bits in x.\r\nExample:\r\n Input  x = 10\r\n Output y is 12\r\nsince 10 in binary is 1010 and 12 in binary is 1100.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 128px; display: block; min-width: 0px; padding-block-start: 0px; padding-inline-start: 2px; padding-left: 2px; padding-top: 0px; perspective-origin: 468.5px 64px; transform-origin: 468.5px 64px; 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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 444.5px 10.5px; text-align: left; transform-origin: 444.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\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: 228.717px 8px; transform-origin: 228.717px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven an unsigned integer x, find the largest y by rearranging the bits in x.\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 444.5px 10.5px; text-align: left; transform-origin: 444.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\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: 29.175px 8px; transform-origin: 29.175px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 36px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 464.5px 18px; transform-origin: 464.5px 18px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; 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; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 464.5px 9px; text-wrap-mode: nowrap; transform-origin: 464.5px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 53.9px 8.5px; tab-size: 4; transform-origin: 53.9px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 30.8px 8.5px; transform-origin: 30.8px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(133, 22, 209); border-block-start-color: rgb(133, 22, 209); border-bottom-color: rgb(133, 22, 209); border-inline-end-color: rgb(133, 22, 209); border-inline-start-color: rgb(133, 22, 209); border-left-color: rgb(133, 22, 209); border-right-color: rgb(133, 22, 209); border-top-color: rgb(133, 22, 209); caret-color: rgb(133, 22, 209); color: rgb(133, 22, 209); column-rule-color: rgb(133, 22, 209); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(133, 22, 209); perspective-origin: 23.1px 8.5px; text-decoration-color: rgb(133, 22, 209); text-emphasis-color: rgb(133, 22, 209); transform-origin: 23.1px 8.5px; \"\u003ex = 10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; 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; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 464.5px 9px; text-wrap-mode: nowrap; transform-origin: 464.5px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 57.75px 8.5px; tab-size: 4; transform-origin: 57.75px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 30.8px 8.5px; transform-origin: 30.8px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(133, 22, 209); border-block-start-color: rgb(133, 22, 209); border-bottom-color: rgb(133, 22, 209); border-inline-end-color: rgb(133, 22, 209); border-inline-start-color: rgb(133, 22, 209); border-left-color: rgb(133, 22, 209); border-right-color: rgb(133, 22, 209); border-top-color: rgb(133, 22, 209); caret-color: rgb(133, 22, 209); color: rgb(133, 22, 209); column-rule-color: rgb(133, 22, 209); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(133, 22, 209); perspective-origin: 26.95px 8.5px; text-decoration-color: rgb(133, 22, 209); text-emphasis-color: rgb(133, 22, 209); transform-origin: 26.95px 8.5px; \"\u003ey is 12\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 444.5px 10.5px; text-align: left; transform-origin: 444.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; \"\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: 156.65px 8px; transform-origin: 156.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince 10 in binary is 1010 and 12 in binary is 1100.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = maxit(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('maxit.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp');\r\nassert(~illegal)\r\n\r\n%%\r\nx = 76;\r\ny_correct = 112;\r\nassert(isequal(maxit(x),y_correct))\r\n%%\r\nx = 555;\r\ny_correct = 992;\r\nassert(isequal(maxit(x),y_correct))\r\n\r\n%%\r\nx = 1000;\r\ny_correct = 1008;\r\nassert(isequal(maxit(x),y_correct))\r\n\r\n%%\r\nx = 10000000;\r\ny_correct = 16711680;\r\nassert(isequal(maxit(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":19,"comments_count":2,"created_by":166,"edited_by":223089,"edited_at":"2026-03-22T08:14:38.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1990,"test_suite_updated_at":"2026-03-22T08:14:38.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-01-26T08:18:49.000Z","updated_at":"2026-03-31T09:15:01.000Z","published_at":"2012-02-03T03:51:13.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\u003eGiven an unsigned integer x, find the largest y by rearranging the bits in x.\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:\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[ Input  x = 10\\n Output y is 12]]\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\u003esince 10 in binary is 1010 and 12 in binary is 1100.\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":42894,"title":"Find longest run","description":"Write a function longest_run that takes as input an array of 0's and 1's and outputs the length and index of the longest consecutive run of either 0's or 1's. If there are multiple runs of the same length, it should output the first occurence.\r\n\r\nExamples:\r\n\r\n1. |longest_run([1 1 0 1])| should output |[2 1]|,\r\nsince the longest consecutive run is 11, which starts at index 1\r\n\r\n2. |longest_run([1 1 0 1 0 0 0 0 1 1 1])| should ouptut |[4 5]|,\r\nsince the longest consecutive run is 0000, which starts at index 5\r\n\r\n3. |longest_run([1 0])| should ouptut |[1 1]|,\r\nsince the _first_ longest consecutive run is 1, which starts at index 1","description_html":"\u003cp\u003eWrite a function longest_run that takes as input an array of 0's and 1's and outputs the length and index of the longest consecutive run of either 0's or 1's. If there are multiple runs of the same length, it should output the first occurence.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003e1. \u003ctt\u003elongest_run([1 1 0 1])\u003c/tt\u003e should output \u003ctt\u003e[2 1]\u003c/tt\u003e,\r\nsince the longest consecutive run is 11, which starts at index 1\u003c/p\u003e\u003cp\u003e2. \u003ctt\u003elongest_run([1 1 0 1 0 0 0 0 1 1 1])\u003c/tt\u003e should ouptut \u003ctt\u003e[4 5]\u003c/tt\u003e,\r\nsince the longest consecutive run is 0000, which starts at index 5\u003c/p\u003e\u003cp\u003e3. \u003ctt\u003elongest_run([1 0])\u003c/tt\u003e should ouptut \u003ctt\u003e[1 1]\u003c/tt\u003e,\r\nsince the \u003ci\u003efirst\u003c/i\u003e longest consecutive run is 1, which starts at index 1\u003c/p\u003e","function_template":"function [run_length, start_index] = longest_run(binary_array)\r\n%longest_run Finds longest consecutive runs of zeros or ones\r\n%   run_length is the length of the longest run of zeros or ones\r\n%   start_index is the index where the run begins\r\n\r\n    run_length = 1;\r\n    start_index = 1;\r\nend","test_suite":"%%\r\nbinary_array = [1 1 0 1];\r\nexpected_length = 2;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1 1 0 1 0 0 0 0 1 1 1];\r\nexpected_length = 4;\r\nexpected_index = 5;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1 0];\r\nexpected_length = 1;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1];\r\nexpected_length = 1;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1 1 1 1 1 1];\r\nexpected_length = 6;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":26948,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":88,"test_suite_updated_at":"2016-06-29T20:27:09.000Z","rescore_all_solutions":false,"group_id":43,"created_at":"2016-06-29T18:38:46.000Z","updated_at":"2026-01-12T14:18:11.000Z","published_at":"2016-06-29T20:27:09.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\u003eWrite a function longest_run that takes as input an array of 0's and 1's and outputs the length and index of the longest consecutive run of either 0's or 1's. If there are multiple runs of the same length, it should output the first occurence.\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\u003eExamples:\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\u003e1.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elongest_run([1 1 0 1])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e should output\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[2 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, since the longest consecutive run is 11, which starts at index 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elongest_run([1 1 0 1 0 0 0 0 1 1 1])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e should ouptut\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[4 5]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, since the longest consecutive run is 0000, which starts at index 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elongest_run([1 0])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e should ouptut\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[1 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, since the\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\u003efirst\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e longest consecutive run is 1, which starts at index 1\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":2046,"title":"Convert binary numbers to hexadecimal numbers","description":"Function must convert the input vector x composed of 0 and 1 (length is a multiple of 8) in hexadecimal. Most significant bit is first. each pair of hexadecimal symbols must be separated by space.\r\n\r\n*Example*:\r\n[1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] will return 'F0 E1'","description_html":"\u003cp\u003eFunction must convert the input vector x composed of 0 and 1 (length is a multiple of 8) in hexadecimal. Most significant bit is first. each pair of hexadecimal symbols must be separated by space.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e:\r\n[1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] will return 'F0 E1'\u003c/p\u003e","function_template":"function y = bin2hex(x)\r\n  y = 'AB CD';\r\nend","test_suite":"%%\r\nx = [1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] ;\r\ny_correct = 'F0 E1';\r\nassert(isequal(bin2hex(x),y_correct));\r\n\r\n%%\r\nx = ones(1,80);\r\ny_correct = 'FF FF FF FF FF FF FF FF FF FF';\r\nassert(isequal(bin2hex(x),y_correct));\r\n\r\n%%\r\nx = zeros(1,8);\r\ny_correct = '00';\r\nassert(isequal(bin2hex(x),y_correct));\r\n\r\n%%\r\nx = '1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 0 1 0';\r\ny_correct = '9E 6B E2 9A';\r\nassert(isequal(bin2hex(x),y_correct));","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":19725,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":46,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-12-13T15:48:33.000Z","updated_at":"2026-01-06T20:29:31.000Z","published_at":"2013-12-13T15:51:02.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\u003eFunction must convert the input vector x composed of 0 and 1 (length is a multiple of 8) in hexadecimal. Most significant bit is first. each pair of hexadecimal symbols must be separated by space.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: [1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] will return 'F0 E1'\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":15,"title":"Find the longest sequence of 1's in a binary sequence.","description":"Given a string such as\n\n s = '011110010000000100010111'\n\nfind the length of the longest string of consecutive 1's. In this example, the answer would be 4.\n\nExample:\n\n Input  x = '110100111'\n Output y is 3","description_html":"\u003cp\u003eGiven a string such as\u003c/p\u003e\u003cpre\u003e s = '011110010000000100010111'\u003c/pre\u003e\u003cp\u003efind the length of the longest string of consecutive 1's. In this example, the answer would be 4.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input  x = '110100111'\n Output y is 3\u003c/pre\u003e","function_template":"function y = lengthOnes(x)\n  y = x\nend","test_suite":"%%\nx = '0';\ny_correct = 0;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '1';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '01';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '10';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '00';\ny_correct = 0;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '11';\n y_correct = 2;\nassert(isequal(lengthOnes(x),y_correct))\n%%\nx = '1111111111';\ny_correct = 10;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '100101011111010011111';\ny_correct = 5;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '01010101010101010101010101';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '0101010111000101110001011100010100001110110100000000110001001000001110001000111010101001101100001111';\ny_correct = 4;\nassert(isequal(lengthOnes(x),y_correct))","published":true,"deleted":false,"likes_count":81,"comments_count":10,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6696,"test_suite_updated_at":"2012-01-18T01:00:19.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:19.000Z","updated_at":"2026-04-03T20:38:16.000Z","published_at":"2012-01-18T01:00:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a string such as\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ s = '011110010000000100010111']]\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\u003efind the length of the longest string of consecutive 1's. In this example, the answer would be 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  x = '110100111'\\n Output y is 3]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":34,"title":"Binary numbers","description":"Given a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return\n\n\u003e\u003e binary_numbers(3)\n\nans =\n\n     1     1     1\n     0     0     0\n     0     1     1\n     0     1     0\n     0     0     1\n     1     0     0\n     1     1     0\n     1     0     1\n\nThe order of the rows does not matter.","description_html":"\u003cp\u003eGiven a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return\u003c/p\u003e\u003cp\u003e\u003e\u003e binary_numbers(3)\u003c/p\u003e\u003cp\u003eans =\u003c/p\u003e\u003cpre\u003e     1     1     1\n     0     0     0\n     0     1     1\n     0     1     0\n     0     0     1\n     1     0     0\n     1     1     0\n     1     0     1\u003c/pre\u003e\u003cp\u003eThe order of the rows does not matter.\u003c/p\u003e","function_template":"function A = binary_numbers(n)\nA = n;","test_suite":"%%\nn = 2;\nA = binary_numbers(n);\nassert(isequal(class(A), 'double'))\n\n%%\nn = 3;\nA = binary_numbers(n);\nassert(all(A(:) == 0 | A(:) == 1))\n\n%%\nn = 5;\nA = binary_numbers(n);\nassert(isequal(size(A),[32 5]))\n\n%%\nn = 10;\nA = binary_numbers(n);\nassert(isequal(size(unique(A,'rows'),1),1024))\n\n%%\nn = 1;\nA = binary_numbers(n);\nassert(isequal(A,[0;1]) || isequal(A,[1;0]))","published":true,"deleted":false,"likes_count":48,"comments_count":12,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4784,"test_suite_updated_at":"2012-01-18T01:00:21.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:21.000Z","updated_at":"2026-04-03T20:45:46.000Z","published_at":"2012-01-18T01:00:21.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u0026gt; binary_numbers(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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eans =\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[     1     1     1\\n     0     0     0\\n     0     1     1\\n     0     1     0\\n     0     0     1\\n     1     0     0\\n     1     1     0\\n     1     0     1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe order of the rows does not matter.\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":2869,"title":"There are 10 types of people in the world","description":"Those who know binary, and those who don't.\r\n\r\nThe number 2015 is a palindrome in binary (11111011111 to be exact)  Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome.  For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911.  You can assume all years are positive integers.\r\n\r\nGood luck!!kcul dooG","description_html":"\u003cp\u003eThose who know binary, and those who don't.\u003c/p\u003e\u003cp\u003eThe number 2015 is a palindrome in binary (11111011111 to be exact)  Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome.  For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911.  You can assume all years are positive integers.\u003c/p\u003e\u003cp\u003eGood luck!!kcul dooG\u003c/p\u003e","function_template":"function y = yearraey(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1881;y_correct = 30;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 2014;y_correct = 1;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 2015;y_correct = 0;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 606;y_correct = 27;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 6006;y_correct = 71;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 60006;y_correct = 369;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nk=zeros(1,15);\r\nfor n=1:15\r\n    y=2^n+2;\r\n    k(n)=yearraey(y);\r\nend\r\ny_correct=[1 1 5 3 11 7 23 15 47 31 95 63 191 127 383];\r\nassert(isequal(k,y_correct))","published":true,"deleted":false,"likes_count":32,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1288,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-01-21T19:54:31.000Z","updated_at":"2026-04-01T10:06:09.000Z","published_at":"2015-01-21T19:54:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eThose who know binary, and those who don't.\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 number 2015 is a palindrome in binary (11111011111 to be exact) Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome. For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911. You can assume all years are positive integers.\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!!kcul dooG\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":43614,"title":"Convert binary numbers array into array of decimal numbers.","description":"Convert binary numbers array into array of decimal numbers.\r\nExample\r\nx=[ 11001000 ; 11001001 ; 11001010 ; 11001011 ; 11001100 ; 11001101 ; 11001110 ; 11001111 ; 11010000 ; 11010001 ; 11010010 ; 11010011 ; 11010100 ; 11010101 ; 11010110 ; 11010111 ; 11011000 ; 11011001 ; 11011010 ; 11011011 ; 11011100 ; 11011101 ; 11011110 ; 11011111 ; 11100000 ; 11100001 ; 11100010 ; 11100011 ; 11100100 ; 11100101 ; 11100110]\r\nres= [ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230]","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: 195px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97.5px; transform-origin: 407px 97.5px; 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: 192px 8px; transform-origin: 192px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eConvert binary numbers array into array of decimal numbers.\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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 382px 8px; transform-origin: 382px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ex=[ 11001000 ; 11001001 ; 11001010 ; 11001011 ; 11001100 ; 11001101 ; 11001110 ; 11001111 ; 11010000 ; 11010001 ; 11010010 ; 11010011 ; 11010100 ; 11010101 ; 11010110 ; 11010111 ; 11011000 ; 11011001 ; 11011010 ; 11011011 ; 11011100 ; 11011101 ; 11011110 ; 11011111 ; 11100000 ; 11100001 ; 11100010 ; 11100011 ; 11100100 ; 11100101 ; 11100110]\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: 375.5px 8px; transform-origin: 375.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eres= [ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = BinToDec(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx=[ \r\n11001000 ;\r\n11001001 ; \r\n11001010 ;\r\n11001011 ;\r\n11001100 ;\r\n11001101 ;\r\n11001110 ;\r\n11001111 ;\r\n11010000 ;\r\n11010001 ;\r\n11010010 ;\r\n11010011 ;\r\n11010100 ;\r\n11010101 ;\r\n11010110 ;\r\n11010111 ; \r\n11011000 ; \r\n11011001 ;\r\n11011010 ; \r\n11011011 ;\r\n11011100 ;\r\n11011101 ; \r\n11011110 ;\r\n11011111 ;\r\n11100000 ; \r\n11100001 ;\r\n11100010 ;\r\n11100011 ;\r\n11100100 ;\r\n11100101 ;\r\n11100110 ];\r\ny_correct =[ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 ; 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230];\r\nassert(isequal(BinToDec(x),y_correct))\r\n%%\r\nx= [ \r\n101000000;\r\n101000001;\r\n101000010;\r\n101000011;\r\n101000100;\r\n101000101;\r\n101000110;\r\n101000111;\r\n101001000;\r\n101001001;\r\n101001010;\r\n101001011;\r\n101001100;\r\n101001101;\r\n101001110;\r\n101001111;\r\n101010000;\r\n101010001;\r\n101010010;\r\n101010011;\r\n101010100 ];\r\ny_correct =[ 320  ; 321  ; 322  ; 323  ; 324  ; 325  ; 326 ;  327  ; 328  ; 329  ; 330 ;  331 ;  332  ; 333  ; 334  ; 335  ; 336 ;  337 ;  338  ; 339  ; 340 ];\r\nassert(isequal(BinToDec(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":90467,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":170,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-24T21:26:58.000Z","updated_at":"2026-03-31T17:53:25.000Z","published_at":"2016-10-24T21:27:38.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\u003eConvert binary numbers array into array of decimal numbers.\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\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\u003ex=[ 11001000 ; 11001001 ; 11001010 ; 11001011 ; 11001100 ; 11001101 ; 11001110 ; 11001111 ; 11010000 ; 11010001 ; 11010010 ; 11010011 ; 11010100 ; 11010101 ; 11010110 ; 11010111 ; 11011000 ; 11011001 ; 11011010 ; 11011011 ; 11011100 ; 11011101 ; 11011110 ; 11011111 ; 11100000 ; 11100001 ; 11100010 ; 11100011 ; 11100100 ; 11100101 ; 11100110]\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\u003eres= [ 200 ; 201 ; 202 ; 203 ; 204 ; 205 ; 206 ; 207 ; 208 ; 209 ; 210 ; 211 ; 212 213 ; 214 ; 215 ; 216 ; 217 ; 218 ; 219 ; 220 ; 221 ; 222 ; 223 ; 224 ; 225 ; 226 ; 227 ; 228 ; 229 ; 230]\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":1338,"title":"Binary Coder","description":"Take an input number and print the binary value of this number.","description_html":"\u003cp\u003eTake an input number and print the binary value of this number.\u003c/p\u003e","function_template":"function y = binary_coder(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 8;\r\ny_correct = 1000;\r\nassert(isequal(binary_coder(x),y_correct))\r\n\r\n%%\r\nx = 24;\r\ny_correct = 11000;\r\nassert(isequal(binary_coder(x),y_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":11534,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":273,"test_suite_updated_at":"2013-03-10T18:56:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-03-10T18:19:00.000Z","updated_at":"2026-03-27T18:21:15.000Z","published_at":"2013-03-10T18:19:00.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\u003eTake an input number and print the binary value of this 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":1861,"title":"Binary","description":"Given a positive, integer n, create a function that returns the respective binary number in the form of a vector.\r\n\r\nExample:\r\n\r\n   input: 3\r\n  output: [1 1]","description_html":"\u003cp\u003eGiven a positive, integer n, create a function that returns the respective binary number in the form of a vector.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e   input: 3\r\n  output: [1 1]\u003c/pre\u003e","function_template":"function y = binary(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = [1];\r\nassert(isequal(binary(n),y_correct))\r\n\r\n%%\r\nn = 7;\r\ny_correct = [1 1 1];\r\nassert(isequal(binary(n),y_correct))\r\n\r\n%%\r\nn = 10;\r\ny_correct = [1 0 1 0];\r\nassert(isequal(binary(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":17224,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":224,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-06T15:49:18.000Z","updated_at":"2026-04-01T12:54:33.000Z","published_at":"2013-09-06T15:49:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive, integer n, create a function that returns the respective binary number in the form of a vector.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   input: 3\\n  output: [1 1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":43977,"title":"Converting binary to decimals","description":"Convert binary to decimals.\r\n\r\nExample:\r\n\r\n010111 = 23. \r\n\r\n110000 = 48.","description_html":"\u003cp\u003eConvert binary to decimals.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003e010111 = 23.\u003c/p\u003e\u003cp\u003e110000 = 48.\u003c/p\u003e","function_template":"function y = bin_to_dec(d)\r\n  y = d;\r\nend","test_suite":"%%\r\nd = ('010111');\r\ny_correct = 23;\r\nassert(isequal(bin_to_dec(d),y_correct))\r\n\r\n%%\r\nd = ('110000');\r\ny_correct = 48;\r\nassert(isequal(bin_to_dec(d),y_correct))\r\n\r\n%%\r\nd = ('1000110');\r\ny_correct = 70;\r\nassert(isequal(bin_to_dec(d),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":108624,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1701,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-29T13:49:15.000Z","updated_at":"2026-04-01T08:57:55.000Z","published_at":"2016-12-29T13:51:20.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConvert binary to decimals.\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:\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\u003e010111 = 23.\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\u003e110000 = 48.\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":2202,"title":"Flip the bit","description":"Given an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').","description_html":"\u003cp\u003eGiven an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').\u003c/p\u003e","function_template":"function y = flipbit(s)\r\n  y = '010101';\r\nend","test_suite":"%%\r\ns = '1001';\r\ny_correct = '0110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '11';\r\ny_correct = '00';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '1';\r\ny_correct = '0';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '100000001';\r\ny_correct = '011111110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '00001';\r\ny_correct = '11110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":2,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":535,"test_suite_updated_at":"2014-02-20T18:44:05.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-02-20T15:53:55.000Z","updated_at":"2026-03-19T20:08:33.000Z","published_at":"2014-02-20T15:56:43.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').\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":2522,"title":"Convert given decimal number to binary number. ","description":"Convert given decimal number to binary number.\r\nExample x=10, then answer must be 1010.","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: 51px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 25.5px; transform-origin: 407px 25.5px; 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: 153px 8px; transform-origin: 153px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eConvert given decimal number to binary number.\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: 133px 8px; transform-origin: 133px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample x=10, then answer must be 1010.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = dec_bin(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 0;\r\nassert(isequal(dec_bin(x),x))\r\n%%\r\nx = 10;\r\ny_correct = 1010;\r\nassert(isequal(dec_bin(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct =  10;\r\nassert(isequal(dec_bin(x),y_correct))\r\n%%\r\nx = 15;\r\ny_correct =  1111;\r\nassert(isequal(dec_bin(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct =  101;\r\nassert(isequal(dec_bin(x),y_correct))","published":true,"deleted":false,"likes_count":20,"comments_count":4,"created_by":27760,"edited_by":223089,"edited_at":"2022-05-02T16:13:29.000Z","deleted_by":null,"deleted_at":null,"solvers_count":2284,"test_suite_updated_at":"2022-05-02T16:13:29.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-20T07:56:26.000Z","updated_at":"2026-04-03T02:25:05.000Z","published_at":"2014-08-20T07:56:26.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\u003eConvert given decimal number to binary number.\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 x=10, then answer must be 1010.\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":1547,"title":"Relative ratio of \"1\" in binary number","description":"Input(n) is positive integer number\r\n\r\nOutput(r) is (number of \"1\" in binary input) / (number of bits).\r\n\r\nExample:\r\n\r\n* n=0; r=0\r\n* n=1; r=1\r\n* n=2; r=0.5\r\n","description_html":"\u003cp\u003eInput(n) is positive integer number\u003c/p\u003e\u003cp\u003eOutput(r) is (number of \"1\" in binary input) / (number of bits).\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cul\u003e\u003cli\u003en=0; r=0\u003c/li\u003e\u003cli\u003en=1; r=1\u003c/li\u003e\u003cli\u003en=2; r=0.5\u003c/li\u003e\u003c/ul\u003e","function_template":"function r = ones_ratio(n)\r\n  r = n;\r\nend","test_suite":"%%\r\nx = 0;\r\ny_correct = 0;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = 0.5;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = 1;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 128;\r\ny_correct = 0.125;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 1265476542;\r\ny_correct = 19/31;\r\nassert(isequal(ones_ratio(x),y_correct))\r\n%%\r\nx = 98917653181;\r\ny_correct = 23/37;\r\nassert(isequal(ones_ratio(x),y_correct))","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":14249,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1599,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-06-04T23:29:28.000Z","updated_at":"2026-04-01T08:15:52.000Z","published_at":"2013-06-04T23:29:28.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\u003eInput(n) is positive integer number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput(r) is (number of \\\"1\\\" in binary input) / (number of bits).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=0; r=0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=1; r=1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en=2; r=0.5\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":2891,"title":"Binary code (array)","description":"Write a function which calculates the binary code of a number 'n' and gives the result as an array(vector).\r\n\r\nExample:\r\n\r\n Input  n = 123\r\n Output y =[1,1,1,1,0,1,1]\r\n\r\n","description_html":"\u003cp\u003eWrite a function which calculates the binary code of a number 'n' and gives the result as an array(vector).\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input  n = 123\r\n Output y =[1,1,1,1,0,1,1]\u003c/pre\u003e","function_template":"function y = dectobin(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2015;\r\ny_correct=[1,1,1,1,1,0,1,1,1,1,1];\r\nassert(isequal(dectobin(x),y_correct))\r\n%%\r\nx = 13;\r\ny_correct=[1,1,0,1];\r\nassert(isequal(dectobin(x),y_correct))\r\n%%\r\nx = 143;\r\ny_correct=[1,0,0,0,1,1,1,1];\r\nassert(isequal(dectobin(x),y_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":33976,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1546,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-01-28T15:49:50.000Z","updated_at":"2026-04-01T08:50:33.000Z","published_at":"2015-01-28T15:54:03.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\u003eWrite a function which calculates the binary code of a number 'n' and gives the result as an array(vector).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  n = 123\\n Output y =[1,1,1,1,0,1,1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":568,"title":"Number of 1s in a binary string","description":"Find the number of 1s in the given binary string.\r\nExample. If the input string is '1100101', the output is 4. If the input string is '0000', the output is 0","description_html":"\u003cp\u003eFind the number of 1s in the given binary string.\r\nExample. If the input string is '1100101', the output is 4. If the input string is '0000', the output is 0\u003c/p\u003e","function_template":"function y = one(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = '0000';\r\ny_correct = 0;\r\nassert(isequal(one(x),y_correct));\r\n\r\n%%\r\nx = '111';\r\ny_correct = 3;\r\nassert(isequal(one(x),y_correct));\r\n\r\n%%\r\nx = '1100101';\r\ny_correct = 4;\r\nassert(isequal(one(x),y_correct));\r\n","published":true,"deleted":false,"likes_count":63,"comments_count":3,"created_by":2974,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11055,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":14,"created_at":"2012-04-10T19:15:07.000Z","updated_at":"2026-04-03T02:22:17.000Z","published_at":"2012-04-10T19:15:11.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\u003eFind the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input string is '0000', the output is 0\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":2678,"title":"Find out sum and carry of Binary adder","description":"Find out sum and carry of a binary adder if previous carry is given with two bits (x and y) for addition. \r\n\r\nExamples\r\n\r\nPrevious carry is 1 and  x=y=1. Addition is 1 and carry is also 1. \r\n\r\nPrevious carry is 0 and  x=y=1. Addition is 0 and carry is also 1. \r\n\r\nPrevious carry is 0 and  x=1, y=0. Addition is 1 and carry is also 0. ","description_html":"\u003cp\u003eFind out sum and carry of a binary adder if previous carry is given with two bits (x and y) for addition.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cp\u003ePrevious carry is 1 and  x=y=1. Addition is 1 and carry is also 1.\u003c/p\u003e\u003cp\u003ePrevious carry is 0 and  x=y=1. Addition is 0 and carry is also 1.\u003c/p\u003e\u003cp\u003ePrevious carry is 0 and  x=1, y=0. Addition is 1 and carry is also 0.\u003c/p\u003e","function_template":"function [sum, carry] = bin_sum_carry(pc,x,y)\r\n  \r\nend","test_suite":"%%\r\nx = 1;\r\ny=1;\r\npc=1;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,1))\r\nassert(isequal(carry,1))\r\n%%\r\nx = 1;\r\ny=1;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,0))\r\nassert(isequal(carry,1))\r\n%%\r\nx = 1;\r\ny=0;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,1))\r\nassert(isequal(carry,0))\r\n%%\r\nx = 0;\r\ny=0;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,0))\r\nassert(isequal(carry,0))\r\n%%\r\nx = 1;\r\ny=1;\r\npc=0;\r\n[sum, carry]=bin_sum_carry(pc,x,y)\r\nassert(isequal(sum,0))\r\nassert(isequal(carry,1))\r\n","published":true,"deleted":false,"likes_count":12,"comments_count":3,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1704,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-11-18T04:58:05.000Z","updated_at":"2026-04-03T20:51:13.000Z","published_at":"2014-11-18T04:58:05.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\u003eFind out sum and carry of a binary adder if previous carry is given with two bits (x and y) for addition.\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\u003eExamples\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\u003ePrevious carry is 1 and x=y=1. Addition is 1 and carry is also 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious carry is 0 and x=y=1. Addition is 0 and carry is also 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePrevious carry is 0 and x=1, y=0. Addition is 1 and carry is also 0.\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":1295,"title":"Bit Reversal","description":"Given an unsigned integer _x_, convert it to binary with _n_ bits, reverse the order of the bits, and convert it back to an integer.","description_html":"\u003cp\u003eGiven an unsigned integer \u003ci\u003ex\u003c/i\u003e, convert it to binary with \u003ci\u003en\u003c/i\u003e bits, reverse the order of the bits, and convert it back to an integer.\u003c/p\u003e","function_template":"function y = bit_reverse(x,n)\r\n  y = 2^n-x;\r\nend","test_suite":"%%\r\nassert(bit_reverse(1,1) == 1)\r\n\r\n%%\r\nassert(bit_reverse(4,3) == 1)\r\n\r\n%%\r\nassert(bit_reverse(2,3) == 2)\r\n\r\n%%\r\nassert(bit_reverse(6,3) == 3)\r\n\r\n%%\r\nassert(bit_reverse(5,3) == 5)\r\n\r\n%%\r\nassert(bit_reverse(7,3) == 7)","published":true,"deleted":false,"likes_count":13,"comments_count":0,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1618,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-02-22T23:16:57.000Z","updated_at":"2026-03-31T11:00:54.000Z","published_at":"2013-02-22T23:16:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an unsigned integer\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\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, convert it to binary with\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e bits, reverse the order of the bits, and convert it back to an 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":108,"title":"Given an unsigned integer x, find the largest y by rearranging the bits in x","description":"Given an unsigned integer x, find the largest y by rearranging the bits in x.\r\nExample:\r\n Input  x = 10\r\n Output y is 12\r\nsince 10 in binary is 1010 and 12 in binary is 1100.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 128px; display: block; min-width: 0px; padding-block-start: 0px; padding-inline-start: 2px; padding-left: 2px; padding-top: 0px; perspective-origin: 468.5px 64px; transform-origin: 468.5px 64px; 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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 444.5px 10.5px; text-align: left; transform-origin: 444.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\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: 228.717px 8px; transform-origin: 228.717px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven an unsigned integer x, find the largest y by rearranging the bits in x.\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; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 444.5px 10.5px; text-align: left; transform-origin: 444.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; \"\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: 29.175px 8px; transform-origin: 29.175px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 36px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 464.5px 18px; transform-origin: 464.5px 18px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; 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; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 464.5px 9px; text-wrap-mode: nowrap; transform-origin: 464.5px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 53.9px 8.5px; tab-size: 4; transform-origin: 53.9px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 30.8px 8.5px; transform-origin: 30.8px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(133, 22, 209); border-block-start-color: rgb(133, 22, 209); border-bottom-color: rgb(133, 22, 209); border-inline-end-color: rgb(133, 22, 209); border-inline-start-color: rgb(133, 22, 209); border-left-color: rgb(133, 22, 209); border-right-color: rgb(133, 22, 209); border-top-color: rgb(133, 22, 209); caret-color: rgb(133, 22, 209); color: rgb(133, 22, 209); column-rule-color: rgb(133, 22, 209); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(133, 22, 209); perspective-origin: 23.1px 8.5px; text-decoration-color: rgb(133, 22, 209); text-emphasis-color: rgb(133, 22, 209); transform-origin: 23.1px 8.5px; \"\u003ex = 10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 18px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; line-height: 18px; 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; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 464.5px 9px; text-wrap-mode: nowrap; transform-origin: 464.5px 9px; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(33, 33, 33); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(33, 33, 33); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(33, 33, 33); border-left-style: none; border-left-width: 0px; border-right-color: rgb(33, 33, 33); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 57.75px 8.5px; tab-size: 4; transform-origin: 57.75px 8.5px; unicode-bidi: normal; white-space-collapse: preserve; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 30.8px 8.5px; transform-origin: 30.8px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(133, 22, 209); border-block-start-color: rgb(133, 22, 209); border-bottom-color: rgb(133, 22, 209); border-inline-end-color: rgb(133, 22, 209); border-inline-start-color: rgb(133, 22, 209); border-left-color: rgb(133, 22, 209); border-right-color: rgb(133, 22, 209); border-top-color: rgb(133, 22, 209); caret-color: rgb(133, 22, 209); color: rgb(133, 22, 209); column-rule-color: rgb(133, 22, 209); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(133, 22, 209); perspective-origin: 26.95px 8.5px; text-decoration-color: rgb(133, 22, 209); text-emphasis-color: rgb(133, 22, 209); transform-origin: 26.95px 8.5px; \"\u003ey is 12\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 444.5px 10.5px; text-align: left; transform-origin: 444.5px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; \"\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: 156.65px 8px; transform-origin: 156.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003esince 10 in binary is 1010 and 12 in binary is 1100.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = maxit(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('maxit.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp');\r\nassert(~illegal)\r\n\r\n%%\r\nx = 76;\r\ny_correct = 112;\r\nassert(isequal(maxit(x),y_correct))\r\n%%\r\nx = 555;\r\ny_correct = 992;\r\nassert(isequal(maxit(x),y_correct))\r\n\r\n%%\r\nx = 1000;\r\ny_correct = 1008;\r\nassert(isequal(maxit(x),y_correct))\r\n\r\n%%\r\nx = 10000000;\r\ny_correct = 16711680;\r\nassert(isequal(maxit(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":19,"comments_count":2,"created_by":166,"edited_by":223089,"edited_at":"2026-03-22T08:14:38.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1990,"test_suite_updated_at":"2026-03-22T08:14:38.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-01-26T08:18:49.000Z","updated_at":"2026-03-31T09:15:01.000Z","published_at":"2012-02-03T03:51:13.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\u003eGiven an unsigned integer x, find the largest y by rearranging the bits in x.\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:\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[ Input  x = 10\\n Output y is 12]]\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\u003esince 10 in binary is 1010 and 12 in binary is 1100.\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":42894,"title":"Find longest run","description":"Write a function longest_run that takes as input an array of 0's and 1's and outputs the length and index of the longest consecutive run of either 0's or 1's. If there are multiple runs of the same length, it should output the first occurence.\r\n\r\nExamples:\r\n\r\n1. |longest_run([1 1 0 1])| should output |[2 1]|,\r\nsince the longest consecutive run is 11, which starts at index 1\r\n\r\n2. |longest_run([1 1 0 1 0 0 0 0 1 1 1])| should ouptut |[4 5]|,\r\nsince the longest consecutive run is 0000, which starts at index 5\r\n\r\n3. |longest_run([1 0])| should ouptut |[1 1]|,\r\nsince the _first_ longest consecutive run is 1, which starts at index 1","description_html":"\u003cp\u003eWrite a function longest_run that takes as input an array of 0's and 1's and outputs the length and index of the longest consecutive run of either 0's or 1's. If there are multiple runs of the same length, it should output the first occurence.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003e1. \u003ctt\u003elongest_run([1 1 0 1])\u003c/tt\u003e should output \u003ctt\u003e[2 1]\u003c/tt\u003e,\r\nsince the longest consecutive run is 11, which starts at index 1\u003c/p\u003e\u003cp\u003e2. \u003ctt\u003elongest_run([1 1 0 1 0 0 0 0 1 1 1])\u003c/tt\u003e should ouptut \u003ctt\u003e[4 5]\u003c/tt\u003e,\r\nsince the longest consecutive run is 0000, which starts at index 5\u003c/p\u003e\u003cp\u003e3. \u003ctt\u003elongest_run([1 0])\u003c/tt\u003e should ouptut \u003ctt\u003e[1 1]\u003c/tt\u003e,\r\nsince the \u003ci\u003efirst\u003c/i\u003e longest consecutive run is 1, which starts at index 1\u003c/p\u003e","function_template":"function [run_length, start_index] = longest_run(binary_array)\r\n%longest_run Finds longest consecutive runs of zeros or ones\r\n%   run_length is the length of the longest run of zeros or ones\r\n%   start_index is the index where the run begins\r\n\r\n    run_length = 1;\r\n    start_index = 1;\r\nend","test_suite":"%%\r\nbinary_array = [1 1 0 1];\r\nexpected_length = 2;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1 1 0 1 0 0 0 0 1 1 1];\r\nexpected_length = 4;\r\nexpected_index = 5;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1 0];\r\nexpected_length = 1;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1];\r\nexpected_length = 1;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));\r\n%%\r\nbinary_array = [1 1 1 1 1 1];\r\nexpected_length = 6;\r\nexpected_index = 1;\r\n[actual_length actual_index] = longest_run(binary_array);\r\nassert(isequal(expected_length, actual_length));\r\nassert(isequal(expected_index, actual_index));","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":26948,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":88,"test_suite_updated_at":"2016-06-29T20:27:09.000Z","rescore_all_solutions":false,"group_id":43,"created_at":"2016-06-29T18:38:46.000Z","updated_at":"2026-01-12T14:18:11.000Z","published_at":"2016-06-29T20:27:09.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\u003eWrite a function longest_run that takes as input an array of 0's and 1's and outputs the length and index of the longest consecutive run of either 0's or 1's. If there are multiple runs of the same length, it should output the first occurence.\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\u003eExamples:\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\u003e1.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elongest_run([1 1 0 1])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e should output\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[2 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, since the longest consecutive run is 11, which starts at index 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elongest_run([1 1 0 1 0 0 0 0 1 1 1])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e should ouptut\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[4 5]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, since the longest consecutive run is 0000, which starts at index 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e3.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elongest_run([1 0])\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e should ouptut\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[1 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, since the\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\u003efirst\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e longest consecutive run is 1, which starts at index 1\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":2046,"title":"Convert binary numbers to hexadecimal numbers","description":"Function must convert the input vector x composed of 0 and 1 (length is a multiple of 8) in hexadecimal. Most significant bit is first. each pair of hexadecimal symbols must be separated by space.\r\n\r\n*Example*:\r\n[1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] will return 'F0 E1'","description_html":"\u003cp\u003eFunction must convert the input vector x composed of 0 and 1 (length is a multiple of 8) in hexadecimal. Most significant bit is first. each pair of hexadecimal symbols must be separated by space.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e:\r\n[1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] will return 'F0 E1'\u003c/p\u003e","function_template":"function y = bin2hex(x)\r\n  y = 'AB CD';\r\nend","test_suite":"%%\r\nx = [1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] ;\r\ny_correct = 'F0 E1';\r\nassert(isequal(bin2hex(x),y_correct));\r\n\r\n%%\r\nx = ones(1,80);\r\ny_correct = 'FF FF FF FF FF FF FF FF FF FF';\r\nassert(isequal(bin2hex(x),y_correct));\r\n\r\n%%\r\nx = zeros(1,8);\r\ny_correct = '00';\r\nassert(isequal(bin2hex(x),y_correct));\r\n\r\n%%\r\nx = '1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 0 1 0';\r\ny_correct = '9E 6B E2 9A';\r\nassert(isequal(bin2hex(x),y_correct));","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":19725,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":46,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-12-13T15:48:33.000Z","updated_at":"2026-01-06T20:29:31.000Z","published_at":"2013-12-13T15:51:02.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\u003eFunction must convert the input vector x composed of 0 and 1 (length is a multiple of 8) in hexadecimal. Most significant bit is first. each pair of hexadecimal symbols must be separated by space.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: [1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] will return 'F0 E1'\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":15,"title":"Find the longest sequence of 1's in a binary sequence.","description":"Given a string such as\n\n s = '011110010000000100010111'\n\nfind the length of the longest string of consecutive 1's. In this example, the answer would be 4.\n\nExample:\n\n Input  x = '110100111'\n Output y is 3","description_html":"\u003cp\u003eGiven a string such as\u003c/p\u003e\u003cpre\u003e s = '011110010000000100010111'\u003c/pre\u003e\u003cp\u003efind the length of the longest string of consecutive 1's. In this example, the answer would be 4.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input  x = '110100111'\n Output y is 3\u003c/pre\u003e","function_template":"function y = lengthOnes(x)\n  y = x\nend","test_suite":"%%\nx = '0';\ny_correct = 0;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '1';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '01';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '10';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '00';\ny_correct = 0;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '11';\n y_correct = 2;\nassert(isequal(lengthOnes(x),y_correct))\n%%\nx = '1111111111';\ny_correct = 10;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '100101011111010011111';\ny_correct = 5;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '01010101010101010101010101';\ny_correct = 1;\nassert(isequal(lengthOnes(x),y_correct))\n\n%%\nx = '0101010111000101110001011100010100001110110100000000110001001000001110001000111010101001101100001111';\ny_correct = 4;\nassert(isequal(lengthOnes(x),y_correct))","published":true,"deleted":false,"likes_count":81,"comments_count":10,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6696,"test_suite_updated_at":"2012-01-18T01:00:19.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:19.000Z","updated_at":"2026-04-03T20:38:16.000Z","published_at":"2012-01-18T01:00:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a string such as\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ s = '011110010000000100010111']]\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\u003efind the length of the longest string of consecutive 1's. In this example, the answer would be 4.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  x = '110100111'\\n Output y is 3]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":34,"title":"Binary numbers","description":"Given a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return\n\n\u003e\u003e binary_numbers(3)\n\nans =\n\n     1     1     1\n     0     0     0\n     0     1     1\n     0     1     0\n     0     0     1\n     1     0     0\n     1     1     0\n     1     0     1\n\nThe order of the rows does not matter.","description_html":"\u003cp\u003eGiven a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return\u003c/p\u003e\u003cp\u003e\u003e\u003e binary_numbers(3)\u003c/p\u003e\u003cp\u003eans =\u003c/p\u003e\u003cpre\u003e     1     1     1\n     0     0     0\n     0     1     1\n     0     1     0\n     0     0     1\n     1     0     0\n     1     1     0\n     1     0     1\u003c/pre\u003e\u003cp\u003eThe order of the rows does not matter.\u003c/p\u003e","function_template":"function A = binary_numbers(n)\nA = n;","test_suite":"%%\nn = 2;\nA = binary_numbers(n);\nassert(isequal(class(A), 'double'))\n\n%%\nn = 3;\nA = binary_numbers(n);\nassert(all(A(:) == 0 | A(:) == 1))\n\n%%\nn = 5;\nA = binary_numbers(n);\nassert(isequal(size(A),[32 5]))\n\n%%\nn = 10;\nA = binary_numbers(n);\nassert(isequal(size(unique(A,'rows'),1),1024))\n\n%%\nn = 1;\nA = binary_numbers(n);\nassert(isequal(A,[0;1]) || isequal(A,[1;0]))","published":true,"deleted":false,"likes_count":48,"comments_count":12,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4784,"test_suite_updated_at":"2012-01-18T01:00:21.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:21.000Z","updated_at":"2026-04-03T20:45:46.000Z","published_at":"2012-01-18T01:00:21.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u0026gt; binary_numbers(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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eans =\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[     1     1     1\\n     0     0     0\\n     0     1     1\\n     0     1     0\\n     0     0     1\\n     1     0     0\\n     1     1     0\\n     1     0     1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe order of the rows does not matter.\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":2869,"title":"There are 10 types of people in the world","description":"Those who know binary, and those who don't.\r\n\r\nThe number 2015 is a palindrome in binary (11111011111 to be exact)  Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome.  For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911.  You can assume all years are positive integers.\r\n\r\nGood luck!!kcul dooG","description_html":"\u003cp\u003eThose who know binary, and those who don't.\u003c/p\u003e\u003cp\u003eThe number 2015 is a palindrome in binary (11111011111 to be exact)  Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome.  For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911.  You can assume all years are positive integers.\u003c/p\u003e\u003cp\u003eGood luck!!kcul dooG\u003c/p\u003e","function_template":"function y = yearraey(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1881;y_correct = 30;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 2014;y_correct = 1;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 2015;y_correct = 0;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 606;y_correct = 27;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 6006;y_correct = 71;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nx = 60006;y_correct = 369;\r\nassert(isequal(yearraey(x),y_correct))\r\n%%\r\nk=zeros(1,15);\r\nfor n=1:15\r\n    y=2^n+2;\r\n    k(n)=yearraey(y);\r\nend\r\ny_correct=[1 1 5 3 11 7 23 15 47 31 95 63 191 127 383];\r\nassert(isequal(k,y_correct))","published":true,"deleted":false,"likes_count":32,"comments_count":4,"created_by":1615,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1288,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-01-21T19:54:31.000Z","updated_at":"2026-04-01T10:06:09.000Z","published_at":"2015-01-21T19:54:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eThose who know binary, and those who don't.\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 number 2015 is a palindrome in binary (11111011111 to be exact) Given a year (in base 10 notation) calculate how many more years it will be until the next year that is a binary palindrome. For example, if you are given the year 1881 (palindrome in base 10! :-), the function should output 30, as the next year that is a binary palindrome is 1911. You can assume all years are positive integers.\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!!kcul dooG\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"group:\"Basics - Binary Logic\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"group:\"Basics - Binary Logic\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Basics - Binary Logic\"","","\"","Basics - Binary Logic","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a01977500\u003e":["Basics - Binary Logic"],"#\u003cMathWorks::Search::Field:0x00007f4a01977460\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a01976b00\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a01977780\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a019776e0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a01977640\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a019775a0\u003e":"group:\"Basics - Binary Logic\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a019775a0\u003e":"group:\"Basics - Binary Logic\""},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f4a01977500\u003e":["Basics - Binary Logic"]}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"group:\"Basics - Binary Logic\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Basics - Binary Logic\"","","\"","Basics - Binary Logic","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a01977500\u003e":["Basics - Binary Logic"],"#\u003cMathWorks::Search::Field:0x00007f4a01977460\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a01976b00\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a01977780\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a019776e0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a01977640\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a019775a0\u003e":"group:\"Basics - Binary Logic\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a019775a0\u003e":"group:\"Basics - Binary Logic\""},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f4a01977500\u003e":["Basics - Binary Logic"]}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":43614,"difficulty_rating":"easy"},{"id":1338,"difficulty_rating":"easy"},{"id":1861,"difficulty_rating":"easy-medium"},{"id":43977,"difficulty_rating":"easy-medium"},{"id":2202,"difficulty_rating":"easy-medium"},{"id":2522,"difficulty_rating":"easy-medium"},{"id":1547,"difficulty_rating":"easy-medium"},{"id":2891,"difficulty_rating":"easy-medium"},{"id":568,"difficulty_rating":"easy-medium"},{"id":2678,"difficulty_rating":"easy-medium"},{"id":1295,"difficulty_rating":"easy-medium"},{"id":108,"difficulty_rating":"easy-medium"},{"id":42894,"difficulty_rating":"medium"},{"id":2046,"difficulty_rating":"medium"},{"id":15,"difficulty_rating":"medium"},{"id":34,"difficulty_rating":"medium"},{"id":2869,"difficulty_rating":"medium"}]}}