{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":2166,"title":"Concatenate a successive power matrix in a column matrix","description":"Generate F = [M1 M^2 ... M^p] with M a matrix, without using for.","description_html":"\u003cp\u003eGenerate F = [M1 M^2 ... M^p] with M a matrix, without using for.\u003c/p\u003e","function_template":"function F = powerConcat(M,p)\r\n  F = M;\r\nend","test_suite":"M=magic(4)\r\np=ceil(4*rand());\r\nF=M;\r\nfor i=2:p\r\nF=[F M^i];\r\nend\r\n%%\r\nassert(isequal(powerConcat(M,p),F))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":19758,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":75,"test_suite_updated_at":"2017-12-06T14:09:14.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-02-07T09:56:02.000Z","updated_at":"2026-02-20T08:37:21.000Z","published_at":"2014-02-07T10:05: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\u003eGenerate F = [M1 M^2 ... M^p] with M a matrix, without using for.\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":3065,"title":"Cycling — Critical Power","description":"From Training and Racing with a Power Meter by Allen and Coggan:\r\n\r\n\"A number of equations have been presented in the scientific literature describing human power output as a function of time, some derived from modeling based on the underlying physiology, and some simply derived empirically. One of the simplest and most robust, though, is the original \"critical power\" concept first proposed by H. Monod around 1960. Various formulations of this idea have been presented, but the original equation is a hyperbolic of the form: t = AWC / (P – CP), where t is time to exhaustion [in seconds], P is current power [in Watts], CP is work rate (i.e., power) asymptote, and AWC is degree of curvature of the relationship.\"\r\n\r\nYou will be given values for AWC and CP. Write a function to return the time that the cyclist can maintain for an array of power (P) values. The times should be rounded to the nearest second. If P \u003c= CP, the cyclist can theoretically maintain that power indefinitely (Inf).","description_html":"\u003cp\u003eFrom Training and Racing with a Power Meter by Allen and Coggan:\u003c/p\u003e\u003cp\u003e\"A number of equations have been presented in the scientific literature describing human power output as a function of time, some derived from modeling based on the underlying physiology, and some simply derived empirically. One of the simplest and most robust, though, is the original \"critical power\" concept first proposed by H. Monod around 1960. Various formulations of this idea have been presented, but the original equation is a hyperbolic of the form: t = AWC / (P – CP), where t is time to exhaustion [in seconds], P is current power [in Watts], CP is work rate (i.e., power) asymptote, and AWC is degree of curvature of the relationship.\"\u003c/p\u003e\u003cp\u003eYou will be given values for AWC and CP. Write a function to return the time that the cyclist can maintain for an array of power (P) values. The times should be rounded to the nearest second. If P \u0026lt;= CP, the cyclist can theoretically maintain that power indefinitely (Inf).\u003c/p\u003e","function_template":"function [t] = cycling_crit_power(AWC,CP,P)\r\n\r\nt = zeros(size(P));\r\n\r\nend\r\n","test_suite":"%%\r\nAWC = 5e4;\r\nCP = 200;\r\nP = [150 200 225 250 275 300 350 400 500 1000];\r\nt_corr = [Inf,Inf,2000,1000,667,500,333,250,167,63];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nAWC = 5.3e4;\r\nCP = 222;\r\nP = [150 200 225 250 275 300 350 400 500 1000];\r\nt_corr = [Inf,Inf,17667,1893,1000,679,414,298,191,68];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nAWC = 4.6e4;\r\nCP = 250;\r\nP = [150 200 225 250 275 300 350 400 500 1000];\r\nt_corr = [Inf,Inf,Inf,Inf,1840,920,460,307,184,61];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nAWC = 5e4;\r\nCP = 300;\r\nP = 250:50:1500;\r\nt_corr = [Inf,Inf,1000,500,333,250,200,167,143,125,111,100,91,83,77,71,67,63,59,56,53,50,48,45,43,42];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tAWC = 5e4;\r\n\t\tCP = 200;\r\n\t\tP = [150 200 225 250 275 300 350 400 500 1000];\r\n\t\tt_corr = [Inf,Inf,2000,1000,667,500,333,250,167,63];\r\n\tcase 2\r\n\t\tAWC = 5.3e4;\r\n\t\tCP = 222;\r\n\t\tP = [150 200 225 250 275 300 350 400 500 1000];\r\n\t\tt_corr = [Inf,Inf,17667,1893,1000,679,414,298,191,68];\r\n\tcase 3\r\n\t\tAWC = 4.6e4;\r\n\t\tCP = 250;\r\n\t\tP = [150 200 225 250 275 300 350 400 500 1000];\r\n\t\tt_corr = [Inf,Inf,Inf,Inf,1840,920,460,307,184,61];\r\n\tcase 4\r\n\t\tAWC = 5e4;\r\n\t\tCP = 300;\r\n\t\tP = 250:50:1500;\r\n\t\tt_corr = [Inf,Inf,1000,500,333,250,200,167,143,125,111,100,91,83,77,71,67,63,59,56,53,50,48,45,43,42];\r\nend\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-05T04:31:29.000Z","updated_at":"2026-02-16T11:45:09.000Z","published_at":"2015-03-05T04:31:29.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\u003eFrom Training and Racing with a Power Meter by Allen and Coggan:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"A number of equations have been presented in the scientific literature describing human power output as a function of time, some derived from modeling based on the underlying physiology, and some simply derived empirically. One of the simplest and most robust, though, is the original \\\"critical power\\\" concept first proposed by H. Monod around 1960. Various formulations of this idea have been presented, but the original equation is a hyperbolic of the form: t = AWC / (P – CP), where t is time to exhaustion [in seconds], P is current power [in Watts], CP is work rate (i.e., power) asymptote, and AWC is degree of curvature of the relationship.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be given values for AWC and CP. Write a function to return the time that the cyclist can maintain for an array of power (P) values. The times should be rounded to the nearest second. If P \u0026lt;= CP, the cyclist can theoretically maintain that power indefinitely (Inf).\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":45593,"title":"Power Numbers","description":"Find the n-th power of m.","description_html":"\u003cp\u003eFind the n-th power of m.\u003c/p\u003e","function_template":"function y = your_fcn_name(x, z)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2;\r\nz = 3;\r\ny_correct = 8;\r\nassert(isequal(your_fcn_name(x,z),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":442253,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":110,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-05-24T19:47:29.000Z","updated_at":"2026-03-09T18:49:41.000Z","published_at":"2020-05-25T18:05: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 n-th power of m.\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":1858,"title":"User defined nextpow function","description":"Create a function which will take 2 arguments as n and x, and return y, where, n^y \u003e= abs(x). [ Similar to builtin \"nextpow2\" function]\r\n\r\ne.g. nextpow(3, 20) will return 3 since 3^3 =27 \u003e 20\r\n\r\nAnother example:\r\nnextpow(4, 16) will return 2, since 4^2 = 16\r\n\r\nnextpow(2, 21) will return 5, since 2^5 = 32 \u003e 21 ","description_html":"\u003cp\u003eCreate a function which will take 2 arguments as n and x, and return y, where, n^y \u003e= abs(x). [ Similar to builtin \"nextpow2\" function]\u003c/p\u003e\u003cp\u003ee.g. nextpow(3, 20) will return 3 since 3^3 =27 \u003e 20\u003c/p\u003e\u003cp\u003eAnother example:\r\nnextpow(4, 16) will return 2, since 4^2 = 16\u003c/p\u003e\u003cp\u003enextpow(2, 21) will return 5, since 2^5 = 32 \u003e 21\u003c/p\u003e","function_template":"function y = nextpow(n,x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 20;\r\nn = 3;\r\ny_correct = 3;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = 16;\r\nn = 4;\r\ny_correct = 2;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = 81;\r\nn = 8;\r\ny_correct = 3;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = 0;\r\nn = 1;\r\ny_correct = 0;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = -32;\r\nn = 2;\r\ny_correct = 5;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = -100;\r\nn = 10;\r\ny_correct = 2;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":16381,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-03T21:51:25.000Z","updated_at":"2026-04-05T13:49:08.000Z","published_at":"2013-09-03T21:51:25.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate a function which will take 2 arguments as n and x, and return y, where, n^y \u003e= abs(x). [ Similar to builtin \\\"nextpow2\\\" function]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ee.g. nextpow(3, 20) will return 3 since 3^3 =27 \u003e 20\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\u003eAnother example: nextpow(4, 16) will return 2, since 4^2 = 16\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\u003enextpow(2, 21) will return 5, since 2^5 = 32 \u003e 21\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":2215,"title":"Power supply: 230V to 115V","description":"The problem is simple: we have a wall outlet which supplies 230V and an apparatus that requires 115V.\r\n\r\nSoftware is always cheaper than hardware (well, most of the time), so we solve this with a program, a Matlab function, to be precise.\r\n\r\nWrite a program that converts the supplied input voltage to the required output voltage.\r\n\r\n*If you like this problem, please like it (after solving).*","description_html":"\u003cp\u003eThe problem is simple: we have a wall outlet which supplies 230V and an apparatus that requires 115V.\u003c/p\u003e\u003cp\u003eSoftware is always cheaper than hardware (well, most of the time), so we solve this with a program, a Matlab function, to be precise.\u003c/p\u003e\u003cp\u003eWrite a program that converts the supplied input voltage to the required output voltage.\u003c/p\u003e\u003cp\u003e\u003cb\u003eIf you like this problem, please like it (after solving).\u003c/b\u003e\u003c/p\u003e","function_template":"function V_out = transformer(V_in)\r\n  N_primary = 5432; % Number of windings on primary coil.\r\n  N_secondary = 2716; % Number of windings on secondary coil.\r\n  V_out = N_secondary*i*V_in/N_primary; % Volt\r\nend","test_suite":"%%\r\nx = 230;\r\ny = transformer(x);\r\ny_correct = 115;\r\nif ~isequal(y,y_correct)\r\ndisp('That is not correct!');\r\ndisp('ÆÆÆÆÆÆÆÆÆÆÆÆÈØ8áÿèqBDüaZF$TWËF®H0ÑÓKÛÆÆÆÈÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÆÆÆÆÉÔ$ÜWÃ§Xwí/+«}{}º°{×}pÔ¿*/\u0026v\u0026F§ÉgÁÂÔÔÔÆÆÆÆÆÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÆÆÆÔÔpæ¼í¢rîC/ìn[**ª°\"²_!*\\\"_^¬ï7\u0026¼n/V2¼ÿ§ÖHÔÆÆÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÆWÐ0õCtîv½»¬°\"¡^¬°³;:²-::÷\";^¬¬³°÷¬(}(}{I¾$ÖE¶MÈÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÛP9{{{ï{}ª°³º°²ª²,:::¨¨¨¸'';::¹¹;²ª*{}|¬}íí\u003ct=åÚBÔÕÆÆÆÆ');\r\ndisp('ÆÆÆÐÿj\u0026£j{/»°°³\"_;;¹;:¸.¸¨¸¸¸¨,¨,''^^°¬¡\"ª¦¦{¿{î46bôBÆÈÑÕÆ');\r\ndisp('ÆÆÆÕKC¿}¦º~²²!^;:¨¸¨¸¨¸··´·.¸¨¸¸¸:;::~~¯°÷÷{(*\u003c}íIàãK¶ÑÑÆ');\r\ndisp('ÆÆÔMýwri¦¯;'':''::¨´.¨  ··  ···`¨¨:;,,¨¨,;²\"°°°\"_°÷{r±¼FÛÆÆ');\r\ndisp('ÆÆ§Tî{¬¬º\":;,¸´¸``.··  · ·····´.´···..`¸¨:;__^¯\"÷{i{zagWÈ');\r\ndisp('ÆÆÖ¼l|²²\"¬²;¸.···   · ·   ······´.¨:_²¨`¸¨:;_ª°¬°¦»}[uaßN');\r\ndisp('ÈÔ©n/÷º\"\"_,¸´····    ·········.´¸¨:::-¹;,::;^°*|{+}}}\u003eJ5F');\r\ndisp('ÆpIc}*«÷²_:¨¸¸`·   ´¸.········.``¸¸¨,;­;;;:;­²\"ª÷¦}»}vI6ë');\r\ndisp('Èdc+¦/}÷\"-:''¨`··  ¨,`.·········´¸¸¸¸,:;_^-::'''';_¡*¦«)t=Yå');\r\ndisp('ÔAu}÷÷¡ª²¹''¸`¸·  ·¨''`.·.·······´``¸¨¨,;­°~:¨¨:;¹;ª¦{|ízÏß');\r\ndisp('Ðs{÷¬º¬_¹;¨¨¸´···¨,''¸`··········`¸¨¨::;-¡º::'':­¹¹^¯^°ºí%p');\r\ndisp('Ëõî}¬¬ª¬;:,´····´,:,,`´´´.····.·´¸¨¨'':­_\"¦­,:::_°¬*°¡\"¬{Y');\r\ndisp('§øL?}}*ª¡²''¸``·´¸::::¨¨_*I}_¨...`¸,^[ôî\\¬{¬;;_^²º¦¬ï{]l}}');\r\ndisp('ß5]«¬°¦{¦^:_ª^_,¸::''²;::_~^~;;¨`¨;¯){ti¬ìïº;^+t¿}*°}i\\tcî');\r\ndisp('ÆS%î}}¦ïI¦^²\"¬°;¸::''­::°nÊÊª^~^¨;(°¬ÊÊLz}*÷;¬ï±sVÌx{»/{?]');\r\ndisp('ÉKg4{¬¦î¼}¯;:_;£ç¦²:''¸,²:²:,:¡~:;}-:;¡°÷°²?{ÂÝ¾5ï5ntÍruz6');\r\ndisp('®k+÷°º¿ii;,;¨¬¸^áIi°¸´`¸¸´·´¨­²­''º*¹:;__²°C+¾án%Iå%j{tI½ç');\r\ndisp('Îv³°+{uu±°;;:*\u003e\"lz{t_¸······¨;¬_¨;{\";::;-¦=\"\u003eïîpîZhtï£awD');\r\ndisp('j)¬×{rxÍ©i¡^*_?¬²Y}c¬:`.····''^{:¸¨¡÷::-²²}{»{}{Y±aYao¢ô®W');\r\ndisp('\u0026l{{?Jnîz¿¬°ª¯lf¬C?ï°::¨´··¸:¬¿¬:;{}:::²°)JYjrYzADhZdÐ#ÆÆ');\r\ndisp('LÌl11îIì[ï°~~°~{ÞÊ©±*,::`.¸'':²²i±¼¦ª~^;²º[ÈÔÆmzôG§ÓÓ¶ÛÔÈÆ');\r\ndisp('WDîî{ïuîv]°\"^«¦÷¿àÕ§/¹::¸¨ªCPEGõ½ð®YCv¬\"}ÔÊÊÊÊËÓèÖÕÔÔÉÆÆÆ');\r\ndisp('ÈÔë±zI[{{÷\"ª°º*{zøÔÊ§¹;­'':\u0026I]tnu}Î¾n¦{\"÷1ÊÊÊÊÊÊÔ®ÖÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÔK\u0026I\\*{*«*¦{{¿±ÆÊÊÊÕ÷°ª;;­:;­²^_­;-°}DÊÊÊÊÊÊÊÊÊÊÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆ#¶©x/il\\tîofbÊÊÊÊÊÊÊMz?²²;:¨¸¸¸'';ª¾ÊIÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÆË');\r\ndisp('ÆÆÆÆÆÆÖÐMÖdøFsÉÊÊÊÊÊÊÊªÎÆÊÊÖJ°-;-_²uÊV;MÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÆÆÆÆÆÈÈÊÊÊÊÊÊÊÊÊÊÊz··!3ÊÊÊÆMËÊë² vÊÔÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÆÆÆÆÆÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÖ¿  ·;¬÷²¸   ¦ÊÅÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÆÆÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ·  ·*42/\u0026bî^:¿ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ:´-ÊÊÊÊÊÊÖÔ^  ½ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆËÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ· :ëÊÊÊÊÊÊ¬  PÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ   ²ÞÊÊÊÊÝ  WÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÉ    {ÊÊÊÊ² ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÅ   ¹ÊÊÊÊÊ:ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊg  µÊÊÊÊËÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ8·gÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('Is this problem a hair-raiser?');\r\nend\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\n% On request of Ned Gulley, some extra testcases (for the, hopefully, stable voltage regulator within the input voltage range specified on the box).\r\nassert(isequal(transformer(173),115))\r\nassert(isequal(transformer(225),115))\r\nassert(isequal(transformer(145),115))\r\nassert(isequal(transformer(238),115))\r\nassert(isequal(transformer(163),115))\r\nassert(isequal(transformer(128),115))\r\nassert(isequal(transformer(216),115))\r\nassert(isequal(transformer(164),115))\r\nassert(isequal(transformer(136),115))\r\nassert(isequal(transformer(156),115))\r\nassert(isequal(transformer(166),115))\r\nassert(isequal(transformer(132),115))\r\nassert(isequal(transformer(162),115))\r\nassert(isequal(transformer(227),115))\r\nassert(isequal(transformer(203),115))\r\nassert(isequal(transformer(168),115))\r\nassert(isequal(transformer(174),115))\r\nassert(isequal(transformer(170),115))\r\nassert(isequal(transformer(161),115))\r\nassert(isequal(transformer(226),115))\r\nassert(isequal(transformer(232),115))\r\nassert(isequal(transformer(146),115))\r\nassert(isequal(transformer(151),115))\r\nassert(isequal(transformer(152),115))\r\nassert(isequal(transformer(193),115))\r\nassert(isequal(transformer(201),115))\r\nassert(isequal(transformer(192),115))\r\nassert(isequal(transformer(133),115))\r\nassert(isequal(transformer(137),115))\r\nassert(isequal(transformer(224),115))\r\nassert(isequal(transformer(200),115))\r\nassert(isequal(transformer(221),115))\r\nassert(isequal(transformer(160),115))\r\nassert(isequal(transformer(230),115))\r\nassert(isequal(transformer(176),115))\r\nassert(isequal(transformer(210),115))\r\nassert(isequal(transformer(159),115))\r\nassert(isequal(transformer(177),115))\r\nassert(isequal(transformer(126),115))\r\nassert(isequal(transformer(197),115))\r\nassert(isequal(transformer(141),115))\r\nassert(isequal(transformer(222),115))\r\nassert(isequal(transformer(189),115))\r\nassert(isequal(transformer(223),115))\r\nassert(isequal(transformer(140),115))\r\nassert(isequal(transformer(231),115))\r\nassert(isequal(transformer(236),115))\r\nassert(isequal(transformer(180),115))\r\nassert(isequal(transformer(191),115))\r\nassert(isequal(transformer(149),115))\r\nassert(isequal(transformer(172),115))\r\nassert(isequal(transformer(196),115))\r\nassert(isequal(transformer(135),115))\r\nassert(isequal(transformer(209),115))\r\nassert(isequal(transformer(144),115))\r\nassert(isequal(transformer(233),115))\r\nassert(isequal(transformer(215),115))\r\nassert(isequal(transformer(204),115))\r\nassert(isequal(transformer(187),115))\r\nassert(isequal(transformer(202),115))\r\nassert(isequal(transformer(217),115))\r\nassert(isequal(transformer(171),115))\r\nassert(isequal(transformer(153),115))\r\nassert(isequal(transformer(139),115))\r\nassert(isequal(transformer(148),115))\r\nassert(isequal(transformer(169),115))\r\nassert(isequal(transformer(130),115))\r\nassert(isequal(transformer(219),115))\r\nassert(isequal(transformer(206),115))\r\nassert(isequal(transformer(127),115))\r\nassert(isequal(transformer(129),115))\r\nassert(isequal(transformer(218),115))\r\nassert(isequal(transformer(220),115))\r\nassert(isequal(transformer(213),115))\r\nassert(isequal(transformer(207),115))\r\nassert(isequal(transformer(188),115))\r\nassert(isequal(transformer(179),115))\r\nassert(isequal(transformer(185),115))\r\nassert(isequal(transformer(131),115))\r\nassert(isequal(transformer(157),115))\r\nassert(isequal(transformer(143),115))\r\nassert(isequal(transformer(147),115))\r\nassert(isequal(transformer(138),115))\r\nassert(isequal(transformer(214),115))\r\nassert(isequal(transformer(178),115))\r\nassert(isequal(transformer(182),115))\r\nassert(isequal(transformer(195),115))\r\nassert(isequal(transformer(237),115))\r\nassert(isequal(transformer(155),115))\r\nassert(isequal(transformer(158),115))\r\nassert(isequal(transformer(199),115))\r\nassert(isequal(transformer(211),115))\r\nassert(isequal(transformer(228),115))\r\nassert(isequal(transformer(175),115))\r\nassert(isequal(transformer(150),115))\r\nassert(isequal(transformer(194),115))\r\nassert(isequal(transformer(134),115))\r\nassert(isequal(transformer(229),115))\r\nassert(isequal(transformer(181),115))\r\nassert(isequal(transformer(190),115))\r\nassert(isequal(transformer(165),115))\r\nassert(isequal(transformer(235),115))\r\nassert(isequal(transformer(239),115))\r\nassert(isequal(transformer(212),115))\r\nassert(isequal(transformer(208),115))\r\nassert(isequal(transformer(142),115))\r\nassert(isequal(transformer(198),115))\r\nassert(isequal(transformer(184),115))\r\nassert(isequal(transformer(240),115))\r\nassert(isequal(transformer(205),115))\r\nassert(isequal(transformer(234),115))\r\nassert(isequal(transformer(186),115))\r\nassert(isequal(transformer(183),115))\r\nassert(isequal(transformer(167),115))\r\nassert(isequal(transformer(154),115))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":108,"test_suite_updated_at":"2014-02-26T08:04:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-24T15:36:09.000Z","updated_at":"2026-02-18T14:03:38.000Z","published_at":"2014-02-24T15:36: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\u003eThe problem is simple: we have a wall outlet which supplies 230V and an apparatus that requires 115V.\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\u003eSoftware is always cheaper than hardware (well, most of the time), so we solve this with a program, a Matlab function, to be precise.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a program that converts the supplied input voltage to the required output voltage.\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\u003eIf you like this problem, please like it (after solving).\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":3064,"title":"Cycling — Normalized Power","description":"In cycling, a power meter is an indispensable tool to record power output (in Watts) and measure fitness gains and performance metrics. When analyzing the data though, many different workouts can yield approximately the same average power, despite major differences between workouts (e.g., a long steady effort vs. sprints or intervals). Normalized power (NP) is a method to measure the effect of more intense efforts on the overall workout. NP is calculated by the following four steps (from Training and Racing with a Power Meter by Allen and Coggan):\r\n\r\n# Calculate a 30-second rolling average of the power data\r\n# Raise these values to the fourth power\r\n# Average the resulting values\r\n# Take the fourth root of the result\r\n\r\nYou will be provided with the 30-second rolling average power data set (vector). Write a function to return the average power (using the rolling average data) and the normalized power using steps 2–4 above. Round the values to the nearest integer.","description_html":"\u003cp\u003eIn cycling, a power meter is an indispensable tool to record power output (in Watts) and measure fitness gains and performance metrics. When analyzing the data though, many different workouts can yield approximately the same average power, despite major differences between workouts (e.g., a long steady effort vs. sprints or intervals). Normalized power (NP) is a method to measure the effect of more intense efforts on the overall workout. NP is calculated by the following four steps (from Training and Racing with a Power Meter by Allen and Coggan):\u003c/p\u003e\u003col\u003e\u003cli\u003eCalculate a 30-second rolling average of the power data\u003c/li\u003e\u003cli\u003eRaise these values to the fourth power\u003c/li\u003e\u003cli\u003eAverage the resulting values\u003c/li\u003e\u003cli\u003eTake the fourth root of the result\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eYou will be provided with the 30-second rolling average power data set (vector). Write a function to return the average power (using the rolling average data) and the normalized power using steps 2–4 above. Round the values to the nearest integer.\u003c/p\u003e","function_template":"function [P_avg,NP] = cycling_norm_power(power)\r\n\r\nP_avg = 0;\r\n\r\nNP = 0;\r\n\r\nend\r\n","test_suite":"%% steady\r\npower = 200*ones(1,3600);\r\nP_avg_corr = 200;\r\nNP_corr = 200;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% intervals\r\npower = 100*ones(1,60);\r\npower = [power 250*ones(1,240)];\r\npower = [power 100*ones(1,60)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 200;\r\nNP_corr = 227;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% ramped intervals\r\npower = 100*ones(1,30);\r\npower = [power 100:249];\r\npower = [power 250:-1:101];\r\npower = [power 100*ones(1,30)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 163;\r\nNP_corr = 182;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% medium sprints\r\npower = 100*ones(1,170);\r\npower = [power 500*ones(1,20)];\r\npower = [power 100*ones(1,170)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 122;\r\nNP_corr = 244;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% intense sprints\r\npower = 100*ones(1,176);\r\npower = [power 1500*ones(1,8)];\r\npower = [power 100*ones(1,176)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 131;\r\nNP_corr = 579;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% anti-cheating (random)\r\nind = randi(5);\r\nswitch ind\r\n\tcase 1\r\n\t\tpower = 200*ones(1,3600);\r\n\t\tP_avg_corr = 200;\r\n\t\tNP_corr = 200;\r\n\tcase 2\r\n\t\tpower = 100*ones(1,60);\r\n\t\tpower = [power 250*ones(1,240)];\r\n\t\tpower = [power 100*ones(1,60)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 200;\r\n\t\tNP_corr = 227;\r\n\tcase 3\r\n\t\tpower = 100*ones(1,30);\r\n\t\tpower = [power 100:249];\r\n\t\tpower = [power 250:-1:101];\r\n\t\tpower = [power 100*ones(1,30)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 163;\r\n\t\tNP_corr = 182;\r\n\tcase 4\r\n\t\tpower = 100*ones(1,170);\r\n\t\tpower = [power 500*ones(1,20)];\r\n\t\tpower = [power 100*ones(1,170)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 122;\r\n\t\tNP_corr = 244;\r\n\tcase 5\r\n\t\tpower = 100*ones(1,176);\r\n\t\tpower = [power 1500*ones(1,8)];\r\n\t\tpower = [power 100*ones(1,176)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 131;\r\n\t\tNP_corr = 579;\r\nend\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-05T03:45:47.000Z","updated_at":"2026-03-31T11:12:20.000Z","published_at":"2015-03-05T03:45:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn cycling, a power meter is an indispensable tool to record power output (in Watts) and measure fitness gains and performance metrics. When analyzing the data though, many different workouts can yield approximately the same average power, despite major differences between workouts (e.g., a long steady effort vs. sprints or intervals). Normalized power (NP) is a method to measure the effect of more intense efforts on the overall workout. NP is calculated by the following four steps (from Training and Racing with a Power Meter by Allen and Coggan):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate a 30-second rolling average of the power data\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRaise these values to the fourth power\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAverage the resulting values\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTake the fourth root of the result\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be provided with the 30-second rolling average power data set (vector). Write a function to return the average power (using the rolling average data) and the normalized power using steps 2–4 above. Round the values to the nearest 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":1441,"title":"Convolution Power","description":"Create the convolution-power vector from initial vector _x_ and power _n_.  In other words, similar to the scalar case, raising to the _n_-th power means repeating the convolution on itself _n_ times. \r\n\r\nAssume that _n_ is a non-negative integer and _x_ is a row vector.\r\n\r\n*Examples*:\r\n\r\n convpower(1:5,0)\r\n ans =\r\n     1\r\n\r\n convpower(1:5,1)\r\n ans = \r\n     1     2     3     4     5\r\n\r\n convpower(1:5,2)\r\n ans = \r\n     1     4    10    20    35    44    46    40    25\r\n\r\nNeither *string operations* nor *interpolations* are allowed!\r\n","description_html":"\u003cp\u003eCreate the convolution-power vector from initial vector \u003ci\u003ex\u003c/i\u003e and power \u003ci\u003en\u003c/i\u003e.  In other words, similar to the scalar case, raising to the \u003ci\u003en\u003c/i\u003e-th power means repeating the convolution on itself \u003ci\u003en\u003c/i\u003e times.\u003c/p\u003e\u003cp\u003eAssume that \u003ci\u003en\u003c/i\u003e is a non-negative integer and \u003ci\u003ex\u003c/i\u003e is a row vector.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e:\u003c/p\u003e\u003cpre\u003e convpower(1:5,0)\r\n ans =\r\n     1\u003c/pre\u003e\u003cpre\u003e convpower(1:5,1)\r\n ans = \r\n     1     2     3     4     5\u003c/pre\u003e\u003cpre\u003e convpower(1:5,2)\r\n ans = \r\n     1     4    10    20    35    44    46    40    25\u003c/pre\u003e\u003cp\u003eNeither \u003cb\u003estring operations\u003c/b\u003e nor \u003cb\u003einterpolations\u003c/b\u003e are allowed!\u003c/p\u003e","function_template":"function y = convpower(x,n)\r\n  y = x;\r\nend","test_suite":"%%\r\nuser_solution = fileread('convpower.m');\r\nassert(isempty(strfind(user_solution,'regexp')));\r\nassert(isempty(strfind(user_solution,'2str')));\r\nassert(isempty(strfind(user_solution,'str2')));\r\nassert(isempty(strfind(user_solution,'interp')));\r\nassert(isempty(strfind(user_solution,'printf')));\r\nassert(isempty(strfind(user_solution,'assert')));\r\n\r\n%%\r\nx = [1 2 3];\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [3 8 1 2 3];\r\nn = 1;\r\ny_correct = [3 8 1 2 3];\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [3 8 1 2 3];\r\nn = 3;\r\ny_correct = [27   216   603   710   570   876   763   354   390   260    63    54    27];\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [1 3 2];\r\nn = 2;\r\ny_correct = [ 1     6    13    12     4];\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [1 1];\r\nn = 10;\r\ny_correct = [ 1    10    45   120   210   252   210   120    45    10     1]\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [1 5 2];\r\nn = 7;\r\ny_correct = [1          35         539        4795       27209      102725      261905      451225      523810      410900      217672 76720       17248        2240         128]\r\nassert(isequal(convpower(x,n),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":10352,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":"2013-04-28T07:05:45.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-04-22T11:04:39.000Z","updated_at":"2026-03-11T08:30:52.000Z","published_at":"2013-04-22T11:07:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate the convolution-power vector from initial vector\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 and power\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. In other words, similar to the scalar case, raising to 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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e-th power means repeating the convolution on itself\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 times.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAssume that\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 is a non-negative integer and\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 is a row 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ convpower(1:5,0)\\n ans =\\n     1\\n\\n convpower(1:5,1)\\n ans = \\n     1     2     3     4     5\\n\\n convpower(1:5,2)\\n ans = \\n     1     4    10    20    35    44    46    40    25]]\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\u003eNeither\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estring operations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e nor\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einterpolations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e are allowed!\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":1786,"title":"Create an index-powered vector","description":"Given a input vector x, return y as index-powered vector as shown below.\r\n\r\nExample\r\n\r\n x = [2 3 6 9]\r\n\r\nthen y should be \r\n\r\n [2^1 3^2 6^3 9^4] = [2 9 216 6561]\r\n","description_html":"\u003cp\u003eGiven a input vector x, return y as index-powered vector as shown below.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre\u003e x = [2 3 6 9]\u003c/pre\u003e\u003cp\u003ethen y should be\u003c/p\u003e\u003cpre\u003e [2^1 3^2 6^3 9^4] = [2 9 216 6561]\u003c/pre\u003e","function_template":"function y = index_power(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [2 3 6 9];\r\ny_correct = [2 9 216 6561];\r\nassert(isequal(index_power(x),y_correct))\r\n\r\n%%\r\nx = [1 5 11 0 -3 -6];\r\ny_correct = [1  25 1331 0 -243 46656];\r\nassert(isequal(index_power(x),y_correct))\r\n\r\n%%\r\nx = [0 8 -12 0 -8 -2];\r\ny_correct = [0 64 -1728 0 -32768 64];\r\nassert(isequal(index_power(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":8,"comments_count":1,"created_by":16381,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":944,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":13,"created_at":"2013-08-12T02:52:55.000Z","updated_at":"2026-04-08T14:23:38.000Z","published_at":"2013-08-12T02:54:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 input vector x, return y as index-powered vector as shown below.\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[ x = [2 3 6 9]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen y should be\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[ [2^1 3^2 6^3 9^4] = [2 9 216 6561]]]\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":60992,"title":"find powers of two","description":"find the unique, non-repeating, powers of 2 that sum to a given non-zero integer, n\r\n\r\nexample:\r\nn = 23\r\nresult = [1 2 4 16]\r\n\r\nthe result does not need to be in any specific order","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: 201px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 100.5px; transform-origin: 408px 100.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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 254.392px 8px; transform-origin: 254.392px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003efind the unique, non-repeating, powers of 2 that sum to a given non-zero integer, n\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 28.4px 8px; transform-origin: 28.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eexample:\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 19.65px 8px; transform-origin: 19.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003en = 23\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 54.2583px 8px; transform-origin: 54.2583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eresult = [1 2 4 16]\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 156.758px 8px; transform-origin: 156.758px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethe result does not need to be in any specific order\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = powersOfTwo(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nx = 24;\r\ny_correct = [8 16];\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 63;\r\ny_correct = [1 2 4 8 16 32];\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 999;\r\ny_correct = [1     2     4    32    64   128   256   512];\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 16;\r\ny_correct = 16;\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":4925929,"edited_by":4925929,"edited_at":"2025-08-27T19:45:31.000Z","deleted_by":null,"deleted_at":null,"solvers_count":16,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2025-08-27T19:44:27.000Z","updated_at":"2026-03-04T12:26:58.000Z","published_at":"2025-08-27T19:45:31.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\u003efind the unique, non-repeating, powers of 2 that sum to a given non-zero integer, n\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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\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\u003en = 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\u003eresult = [1 2 4 16]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethe result does not need to be in any specific order\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":2431,"title":"Power Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:38)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 8:23)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:28)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 9:23)\r\n\r\nExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:38)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 8:23)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:28)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 9:23)\u003c/pre\u003e\u003cp\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = power_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '2:38';\r\ny_correct = 1;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '8:23';\r\ny_correct = 100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '3:28';\r\ny_correct = 10;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '9:23';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '7:22';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:31';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:22';\r\ny_correct = 1100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:12';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":8,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:00:06.000Z","updated_at":"2026-01-15T14:21:57.000Z","published_at":"2014-07-15T18:00:06.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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\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[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:38)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 8:23)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:28)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 9:23)]]\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\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=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\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"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":42454,"title":"Divisible by n, prime divisors (including powers)","description":"For this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\r\n\r\n  n = 1:10;\r\n  n_p = [2 3 4 5 7 8 9];\r\n\r\nSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e.","description_html":"\u003cp\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1:10;\r\nn_p = [2 3 4 5 7 8 9];\r\n\u003c/pre\u003e\u003cp\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_p] = prime_divisors_incl_powers(n)\r\n\r\nn_p = 1;\r\n\r\nend","test_suite":"%%\r\nn = 1:10;\r\nn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = [2:7 12:17 10 42:55 11 19:29];\r\nn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1:100;\r\nn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 41:59;\r\nn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 100:200;\r\nn_p = [101 103 107 109 113 121 125 127 128 131 137 139 149 151 157 163 167 169 173 179 181 191 193 197 199]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1000:1111;\r\nn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:10;\r\n\t\tn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 3\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\n\tcase 3\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = 1000:1111;\r\n\t\tn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":95,"test_suite_updated_at":"2017-03-20T19:03:08.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:55:28.000Z","updated_at":"2026-01-11T12:28:45.000Z","published_at":"2015-07-09T01:55: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\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\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[n = 1:10;\\nn_p = [2 3 4 5 7 8 9];]]\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\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"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":42453,"title":"Divisible by n, prime vs. composite divisors","description":"In general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\r\n\r\n  n = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\n  n = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\n  n = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\n  n = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\n  n = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\n  n = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\n  n = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\n  n = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\n  n = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\n  n = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16 divisible by 16\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e.","description_html":"\u003cp\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\"\u003edivisible by 16\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_type,hpf] = composite_vs_prime_divisor(n)\r\n\r\nn_type = 1;\r\nhpf = [1];\r\n\r\nend\r\n","test_suite":"%%\r\nn = 5;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 5;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 7;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 7;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 15;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,5];\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 25;\r\ntf_corr = 2; %composite factor, prime power (5^2)\r\nhpf_corr = 25;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 125;\r\ntf_corr = 2; %composite factor, prime power (5^3)\r\nhpf_corr = 125;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 20;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [4,5];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 42;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,3,7];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 18;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,9];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 29;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 29;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 39;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,13];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 64;\r\ntf_corr = 2; %composite factor, prime power (2^6)\r\nhpf_corr = 64;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 27;\r\ntf_corr = 2; %composite factor, prime power (3^3)\r\nhpf_corr = 27;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 29;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 29;\r\n\tcase 2\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 64;\r\n\t\ttf_corr = 2; %composite factor, prime power (2^6)\r\n\t\thpf_corr = 64;\r\n\tcase 2\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\n\tcase 3\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 4\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 39;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [3,13];\r\n\tcase 2\r\n\t\tn = 5;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 5;\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":113,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:29:13.000Z","updated_at":"2026-01-11T11:07:59.000Z","published_at":"2015-07-09T01:29:13.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\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\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[n = 11  |  n_type = 1 (prime)        |  hpf = [11]\\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])]]\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\\\"\u003e\u003cw:r\u003e\u003cw:t\u003edivisible by 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"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":44344,"title":"The 5th Root","description":"Write a function to find the 5th root of a number.\r\n\r\nIt sounds easy, but the typical functions are not allowed (see the test suite), so you'll need to find a non-standard method to solve the problem.","description_html":"\u003cp\u003eWrite a function to find the 5th root of a number.\u003c/p\u003e\u003cp\u003eIt sounds easy, but the typical functions are not allowed (see the test suite), so you'll need to find a non-standard method to solve the problem.\u003c/p\u003e","function_template":"function f = fifth_root(n)\r\n f = n^(1/5)\r\nend","test_suite":"%%\r\nfiletext = fileread('fifth_root.m');\r\nassert(isempty(strfind(filetext, '^')),'^ forbidden')\r\nassert(isempty(strfind(filetext, 'power')),'power() forbidden')\r\nassert(isempty(strfind(filetext, 'mpower')),'mpower() forbidden')\r\nassert(isempty(strfind(filetext, 'realpow')),'realpow() forbidden')\r\nassert(isempty(strfind(filetext, 'nthroot')),'nthroot() forbidden')\r\nassert(isempty(strfind(filetext, 'roots')),'roots() forbidden')\r\n\r\n%%\r\nn = 1/9765625;\r\nassert(abs(fifth_root(n)-1/25)\u003c1e-5)\r\n\r\n%%\r\nn = 1/5555;\r\nassert(abs(fifth_root(n)-0.178263811215444)\u003c1e-5)\r\n\r\n%%\r\nn = 1/3125;\r\nassert(abs(fifth_root(n)-1/5)\u003c1e-5)\r\n\r\n%%\r\nn = 1/125;\r\nassert(abs(fifth_root(n)-0.380730787743176)\u003c1e-5)\r\n\r\n%%\r\nn = 1/5;\r\nassert(abs(fifth_root(n)-0.724779663677696)\u003c1e-5)\r\n\r\n%%\r\nn = 1;\r\nassert(abs(fifth_root(n)-1)\u003c1e-5)\r\n\r\n%%\r\nn = 5;\r\nassert(abs(fifth_root(n)-1.37972966146121)\u003c1e-5)\r\n\r\n%%\r\nn = 25;\r\nassert(abs(fifth_root(n)-1.90365393871588)\u003c1e-5)\r\n\r\n%%\r\nn = 50;\r\nassert(abs(fifth_root(n)-2.18672414788656)\u003c1e-5)\r\n\r\n%%\r\nn = 500;\r\nassert(abs(fifth_root(n)-3.46572421577573)\u003c1e-5)\r\n\r\n%%\r\nn = 3125;\r\nassert(abs(fifth_root(n)-5)\u003c1e-5)\r\n\r\n%%\r\nn = 759375;\r\nassert(abs(fifth_root(n)-15)\u003c1e-5)\r\n\r\n%%\r\nn = 9765625;\r\nassert(abs(fifth_root(n)-25)\u003c1e-5)\r\n\r\n%%\r\nn = 312500000;\r\nassert(abs(fifth_root(n)-50)\u003c1e-5)\r\n\r\n%%\r\nn = 75937500000;\r\nassert(abs(fifth_root(n)-150)\u003c1e-5)\r\n\r\n%%\r\nn = 31250000000000;\r\nassert(abs(fifth_root(n)-500)\u003c1e-5)\r\n\r\n%%\r\nn = 52658067346875;\r\nassert(abs(fifth_root(n)-555)\u003c1e-5)","published":true,"deleted":false,"likes_count":13,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":559,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-09-22T16:03:40.000Z","updated_at":"2026-02-03T09:23:18.000Z","published_at":"2017-10-16T01:50:59.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\u003eWrite a function to find the 5th root of a 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\u003eIt sounds easy, but the typical functions are not allowed (see the test suite), so you'll need to find a non-standard method to solve the problem.\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":2396,"title":"last n digit of a power function","description":"Calculate the power of a given a base, exponent. Return the last n digit number.\r\n\r\n  Example 1:\r\n  base = 3; expo = 8; n = 3;\r\n  3^8 = 6561\r\n  return the last 3 digit number 561.\r\n\r\n  Example 2:\r\n  base = 3; expo = 10; n = 3;\r\n  3^10 = 59049\r\n  return the last 3 digit number 49.\r\n\r\n* base, exponent and n are natural numbers","description_html":"\u003cp\u003eCalculate the power of a given a base, exponent. Return the last n digit number.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eExample 1:\r\nbase = 3; expo = 8; n = 3;\r\n3^8 = 6561\r\nreturn the last 3 digit number 561.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eExample 2:\r\nbase = 3; expo = 10; n = 3;\r\n3^10 = 59049\r\nreturn the last 3 digit number 49.\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003ebase, exponent and n are natural numbers\u003c/li\u003e\u003c/ul\u003e","function_template":"function res = lastndigit(base,expo,n)\r\n  res = n;\r\nend","test_suite":"%%\r\nbase = 3; expo = 8; n = 2;\r\ny_correct = 61;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n\r\n%%\r\nbase = 7; expo = 12; n  = 5;\r\ny_correct = 87201;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n\r\n%%\r\nbase = 25; expo = 71; n = 15;\r\ny_correct = 896881103515625;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n\r\n%%\r\nbase = 768; expo = 1579; n = 22;\r\ny_correct = 3750595090000885317632;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":27005,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-06-30T16:29:27.000Z","updated_at":"2014-06-30T16:32:13.000Z","published_at":"2014-06-30T16:31: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\",\"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\u003eCalculate the power of a given a base, exponent. Return the last n digit number.\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[Example 1:\\nbase = 3; expo = 8; n = 3;\\n3^8 = 6561\\nreturn the last 3 digit number 561.\\n\\nExample 2:\\nbase = 3; expo = 10; n = 3;\\n3^10 = 59049\\nreturn the last 3 digit number 49.]]\u003e\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\u003ebase, exponent and n are natural numbers\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":2433,"title":"Consecutive Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\r\n\r\nFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/p\u003e\u003cp\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e.\u003c/p\u003e","function_template":"function [t_s,num] = equation_times_run(times)\r\n t_s = '0:00';\r\n num = 0;\r\nend","test_suite":"%%\r\ntimes = {'1:00' '1:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'2:07' '2:29'};\r\ny_correct = ['2:11' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'3:03' '4:04'};\r\ny_correct = ['3:11' 4];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '7:11'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'7:17' '9:00'};\r\ny_correct = ['8:17' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '9:00'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'1:00' '9:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T19:39:50.000Z","updated_at":"2026-01-15T14:27:21.000Z","published_at":"2014-07-15T19:39:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\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\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"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":2166,"title":"Concatenate a successive power matrix in a column matrix","description":"Generate F = [M1 M^2 ... M^p] with M a matrix, without using for.","description_html":"\u003cp\u003eGenerate F = [M1 M^2 ... M^p] with M a matrix, without using for.\u003c/p\u003e","function_template":"function F = powerConcat(M,p)\r\n  F = M;\r\nend","test_suite":"M=magic(4)\r\np=ceil(4*rand());\r\nF=M;\r\nfor i=2:p\r\nF=[F M^i];\r\nend\r\n%%\r\nassert(isequal(powerConcat(M,p),F))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":19758,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":75,"test_suite_updated_at":"2017-12-06T14:09:14.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-02-07T09:56:02.000Z","updated_at":"2026-02-20T08:37:21.000Z","published_at":"2014-02-07T10:05: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\u003eGenerate F = [M1 M^2 ... M^p] with M a matrix, without using for.\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":3065,"title":"Cycling — Critical Power","description":"From Training and Racing with a Power Meter by Allen and Coggan:\r\n\r\n\"A number of equations have been presented in the scientific literature describing human power output as a function of time, some derived from modeling based on the underlying physiology, and some simply derived empirically. One of the simplest and most robust, though, is the original \"critical power\" concept first proposed by H. Monod around 1960. Various formulations of this idea have been presented, but the original equation is a hyperbolic of the form: t = AWC / (P – CP), where t is time to exhaustion [in seconds], P is current power [in Watts], CP is work rate (i.e., power) asymptote, and AWC is degree of curvature of the relationship.\"\r\n\r\nYou will be given values for AWC and CP. Write a function to return the time that the cyclist can maintain for an array of power (P) values. The times should be rounded to the nearest second. If P \u003c= CP, the cyclist can theoretically maintain that power indefinitely (Inf).","description_html":"\u003cp\u003eFrom Training and Racing with a Power Meter by Allen and Coggan:\u003c/p\u003e\u003cp\u003e\"A number of equations have been presented in the scientific literature describing human power output as a function of time, some derived from modeling based on the underlying physiology, and some simply derived empirically. One of the simplest and most robust, though, is the original \"critical power\" concept first proposed by H. Monod around 1960. Various formulations of this idea have been presented, but the original equation is a hyperbolic of the form: t = AWC / (P – CP), where t is time to exhaustion [in seconds], P is current power [in Watts], CP is work rate (i.e., power) asymptote, and AWC is degree of curvature of the relationship.\"\u003c/p\u003e\u003cp\u003eYou will be given values for AWC and CP. Write a function to return the time that the cyclist can maintain for an array of power (P) values. The times should be rounded to the nearest second. If P \u0026lt;= CP, the cyclist can theoretically maintain that power indefinitely (Inf).\u003c/p\u003e","function_template":"function [t] = cycling_crit_power(AWC,CP,P)\r\n\r\nt = zeros(size(P));\r\n\r\nend\r\n","test_suite":"%%\r\nAWC = 5e4;\r\nCP = 200;\r\nP = [150 200 225 250 275 300 350 400 500 1000];\r\nt_corr = [Inf,Inf,2000,1000,667,500,333,250,167,63];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nAWC = 5.3e4;\r\nCP = 222;\r\nP = [150 200 225 250 275 300 350 400 500 1000];\r\nt_corr = [Inf,Inf,17667,1893,1000,679,414,298,191,68];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nAWC = 4.6e4;\r\nCP = 250;\r\nP = [150 200 225 250 275 300 350 400 500 1000];\r\nt_corr = [Inf,Inf,Inf,Inf,1840,920,460,307,184,61];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nAWC = 5e4;\r\nCP = 300;\r\nP = 250:50:1500;\r\nt_corr = [Inf,Inf,1000,500,333,250,200,167,143,125,111,100,91,83,77,71,67,63,59,56,53,50,48,45,43,42];\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tAWC = 5e4;\r\n\t\tCP = 200;\r\n\t\tP = [150 200 225 250 275 300 350 400 500 1000];\r\n\t\tt_corr = [Inf,Inf,2000,1000,667,500,333,250,167,63];\r\n\tcase 2\r\n\t\tAWC = 5.3e4;\r\n\t\tCP = 222;\r\n\t\tP = [150 200 225 250 275 300 350 400 500 1000];\r\n\t\tt_corr = [Inf,Inf,17667,1893,1000,679,414,298,191,68];\r\n\tcase 3\r\n\t\tAWC = 4.6e4;\r\n\t\tCP = 250;\r\n\t\tP = [150 200 225 250 275 300 350 400 500 1000];\r\n\t\tt_corr = [Inf,Inf,Inf,Inf,1840,920,460,307,184,61];\r\n\tcase 4\r\n\t\tAWC = 5e4;\r\n\t\tCP = 300;\r\n\t\tP = 250:50:1500;\r\n\t\tt_corr = [Inf,Inf,1000,500,333,250,200,167,143,125,111,100,91,83,77,71,67,63,59,56,53,50,48,45,43,42];\r\nend\r\nassert(isequal(cycling_crit_power(AWC,CP,P),t_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-05T04:31:29.000Z","updated_at":"2026-02-16T11:45:09.000Z","published_at":"2015-03-05T04:31:29.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\u003eFrom Training and Racing with a Power Meter by Allen and Coggan:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"A number of equations have been presented in the scientific literature describing human power output as a function of time, some derived from modeling based on the underlying physiology, and some simply derived empirically. One of the simplest and most robust, though, is the original \\\"critical power\\\" concept first proposed by H. Monod around 1960. Various formulations of this idea have been presented, but the original equation is a hyperbolic of the form: t = AWC / (P – CP), where t is time to exhaustion [in seconds], P is current power [in Watts], CP is work rate (i.e., power) asymptote, and AWC is degree of curvature of the relationship.\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be given values for AWC and CP. Write a function to return the time that the cyclist can maintain for an array of power (P) values. The times should be rounded to the nearest second. If P \u0026lt;= CP, the cyclist can theoretically maintain that power indefinitely (Inf).\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":45593,"title":"Power Numbers","description":"Find the n-th power of m.","description_html":"\u003cp\u003eFind the n-th power of m.\u003c/p\u003e","function_template":"function y = your_fcn_name(x, z)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2;\r\nz = 3;\r\ny_correct = 8;\r\nassert(isequal(your_fcn_name(x,z),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":442253,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":110,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-05-24T19:47:29.000Z","updated_at":"2026-03-09T18:49:41.000Z","published_at":"2020-05-25T18:05: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 n-th power of m.\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":1858,"title":"User defined nextpow function","description":"Create a function which will take 2 arguments as n and x, and return y, where, n^y \u003e= abs(x). [ Similar to builtin \"nextpow2\" function]\r\n\r\ne.g. nextpow(3, 20) will return 3 since 3^3 =27 \u003e 20\r\n\r\nAnother example:\r\nnextpow(4, 16) will return 2, since 4^2 = 16\r\n\r\nnextpow(2, 21) will return 5, since 2^5 = 32 \u003e 21 ","description_html":"\u003cp\u003eCreate a function which will take 2 arguments as n and x, and return y, where, n^y \u003e= abs(x). [ Similar to builtin \"nextpow2\" function]\u003c/p\u003e\u003cp\u003ee.g. nextpow(3, 20) will return 3 since 3^3 =27 \u003e 20\u003c/p\u003e\u003cp\u003eAnother example:\r\nnextpow(4, 16) will return 2, since 4^2 = 16\u003c/p\u003e\u003cp\u003enextpow(2, 21) will return 5, since 2^5 = 32 \u003e 21\u003c/p\u003e","function_template":"function y = nextpow(n,x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 20;\r\nn = 3;\r\ny_correct = 3;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = 16;\r\nn = 4;\r\ny_correct = 2;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = 81;\r\nn = 8;\r\ny_correct = 3;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = 0;\r\nn = 1;\r\ny_correct = 0;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = -32;\r\nn = 2;\r\ny_correct = 5;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n%%\r\nx = -100;\r\nn = 10;\r\ny_correct = 2;\r\nassert(isequal(nextpow(n,x),y_correct));\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":16381,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-03T21:51:25.000Z","updated_at":"2026-04-05T13:49:08.000Z","published_at":"2013-09-03T21:51:25.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate a function which will take 2 arguments as n and x, and return y, where, n^y \u003e= abs(x). [ Similar to builtin \\\"nextpow2\\\" function]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ee.g. nextpow(3, 20) will return 3 since 3^3 =27 \u003e 20\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\u003eAnother example: nextpow(4, 16) will return 2, since 4^2 = 16\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\u003enextpow(2, 21) will return 5, since 2^5 = 32 \u003e 21\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":2215,"title":"Power supply: 230V to 115V","description":"The problem is simple: we have a wall outlet which supplies 230V and an apparatus that requires 115V.\r\n\r\nSoftware is always cheaper than hardware (well, most of the time), so we solve this with a program, a Matlab function, to be precise.\r\n\r\nWrite a program that converts the supplied input voltage to the required output voltage.\r\n\r\n*If you like this problem, please like it (after solving).*","description_html":"\u003cp\u003eThe problem is simple: we have a wall outlet which supplies 230V and an apparatus that requires 115V.\u003c/p\u003e\u003cp\u003eSoftware is always cheaper than hardware (well, most of the time), so we solve this with a program, a Matlab function, to be precise.\u003c/p\u003e\u003cp\u003eWrite a program that converts the supplied input voltage to the required output voltage.\u003c/p\u003e\u003cp\u003e\u003cb\u003eIf you like this problem, please like it (after solving).\u003c/b\u003e\u003c/p\u003e","function_template":"function V_out = transformer(V_in)\r\n  N_primary = 5432; % Number of windings on primary coil.\r\n  N_secondary = 2716; % Number of windings on secondary coil.\r\n  V_out = N_secondary*i*V_in/N_primary; % Volt\r\nend","test_suite":"%%\r\nx = 230;\r\ny = transformer(x);\r\ny_correct = 115;\r\nif ~isequal(y,y_correct)\r\ndisp('That is not correct!');\r\ndisp('ÆÆÆÆÆÆÆÆÆÆÆÆÈØ8áÿèqBDüaZF$TWËF®H0ÑÓKÛÆÆÆÈÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÆÆÆÆÉÔ$ÜWÃ§Xwí/+«}{}º°{×}pÔ¿*/\u0026v\u0026F§ÉgÁÂÔÔÔÆÆÆÆÆÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÆÆÆÔÔpæ¼í¢rîC/ìn[**ª°\"²_!*\\\"_^¬ï7\u0026¼n/V2¼ÿ§ÖHÔÆÆÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÆWÐ0õCtîv½»¬°\"¡^¬°³;:²-::÷\";^¬¬³°÷¬(}(}{I¾$ÖE¶MÈÆÆÆÆÆÆ');\r\ndisp('ÆÆÆÛP9{{{ï{}ª°³º°²ª²,:::¨¨¨¸'';::¹¹;²ª*{}|¬}íí\u003ct=åÚBÔÕÆÆÆÆ');\r\ndisp('ÆÆÆÐÿj\u0026£j{/»°°³\"_;;¹;:¸.¸¨¸¸¸¨,¨,''^^°¬¡\"ª¦¦{¿{î46bôBÆÈÑÕÆ');\r\ndisp('ÆÆÆÕKC¿}¦º~²²!^;:¨¸¨¸¨¸··´·.¸¨¸¸¸:;::~~¯°÷÷{(*\u003c}íIàãK¶ÑÑÆ');\r\ndisp('ÆÆÔMýwri¦¯;'':''::¨´.¨  ··  ···`¨¨:;,,¨¨,;²\"°°°\"_°÷{r±¼FÛÆÆ');\r\ndisp('ÆÆ§Tî{¬¬º\":;,¸´¸``.··  · ·····´.´···..`¸¨:;__^¯\"÷{i{zagWÈ');\r\ndisp('ÆÆÖ¼l|²²\"¬²;¸.···   · ·   ······´.¨:_²¨`¸¨:;_ª°¬°¦»}[uaßN');\r\ndisp('ÈÔ©n/÷º\"\"_,¸´····    ·········.´¸¨:::-¹;,::;^°*|{+}}}\u003eJ5F');\r\ndisp('ÆpIc}*«÷²_:¨¸¸`·   ´¸.········.``¸¸¨,;­;;;:;­²\"ª÷¦}»}vI6ë');\r\ndisp('Èdc+¦/}÷\"-:''¨`··  ¨,`.·········´¸¸¸¸,:;_^-::'''';_¡*¦«)t=Yå');\r\ndisp('ÔAu}÷÷¡ª²¹''¸`¸·  ·¨''`.·.·······´``¸¨¨,;­°~:¨¨:;¹;ª¦{|ízÏß');\r\ndisp('Ðs{÷¬º¬_¹;¨¨¸´···¨,''¸`··········`¸¨¨::;-¡º::'':­¹¹^¯^°ºí%p');\r\ndisp('Ëõî}¬¬ª¬;:,´····´,:,,`´´´.····.·´¸¨¨'':­_\"¦­,:::_°¬*°¡\"¬{Y');\r\ndisp('§øL?}}*ª¡²''¸``·´¸::::¨¨_*I}_¨...`¸,^[ôî\\¬{¬;;_^²º¦¬ï{]l}}');\r\ndisp('ß5]«¬°¦{¦^:_ª^_,¸::''²;::_~^~;;¨`¨;¯){ti¬ìïº;^+t¿}*°}i\\tcî');\r\ndisp('ÆS%î}}¦ïI¦^²\"¬°;¸::''­::°nÊÊª^~^¨;(°¬ÊÊLz}*÷;¬ï±sVÌx{»/{?]');\r\ndisp('ÉKg4{¬¦î¼}¯;:_;£ç¦²:''¸,²:²:,:¡~:;}-:;¡°÷°²?{ÂÝ¾5ï5ntÍruz6');\r\ndisp('®k+÷°º¿ii;,;¨¬¸^áIi°¸´`¸¸´·´¨­²­''º*¹:;__²°C+¾án%Iå%j{tI½ç');\r\ndisp('Îv³°+{uu±°;;:*\u003e\"lz{t_¸······¨;¬_¨;{\";::;-¦=\"\u003eïîpîZhtï£awD');\r\ndisp('j)¬×{rxÍ©i¡^*_?¬²Y}c¬:`.····''^{:¸¨¡÷::-²²}{»{}{Y±aYao¢ô®W');\r\ndisp('\u0026l{{?Jnîz¿¬°ª¯lf¬C?ï°::¨´··¸:¬¿¬:;{}:::²°)JYjrYzADhZdÐ#ÆÆ');\r\ndisp('LÌl11îIì[ï°~~°~{ÞÊ©±*,::`.¸'':²²i±¼¦ª~^;²º[ÈÔÆmzôG§ÓÓ¶ÛÔÈÆ');\r\ndisp('WDîî{ïuîv]°\"^«¦÷¿àÕ§/¹::¸¨ªCPEGõ½ð®YCv¬\"}ÔÊÊÊÊËÓèÖÕÔÔÉÆÆÆ');\r\ndisp('ÈÔë±zI[{{÷\"ª°º*{zøÔÊ§¹;­'':\u0026I]tnu}Î¾n¦{\"÷1ÊÊÊÊÊÊÔ®ÖÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÔK\u0026I\\*{*«*¦{{¿±ÆÊÊÊÕ÷°ª;;­:;­²^_­;-°}DÊÊÊÊÊÊÊÊÊÊÆÆÆÆÆÆÆ');\r\ndisp('ÆÆÆ#¶©x/il\\tîofbÊÊÊÊÊÊÊMz?²²;:¨¸¸¸'';ª¾ÊIÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÆË');\r\ndisp('ÆÆÆÆÆÆÖÐMÖdøFsÉÊÊÊÊÊÊÊªÎÆÊÊÖJ°-;-_²uÊV;MÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÆÆÆÆÆÈÈÊÊÊÊÊÊÊÊÊÊÊz··!3ÊÊÊÆMËÊë² vÊÔÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÆÆÆÆÆÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÖ¿  ·;¬÷²¸   ¦ÊÅÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÆÆÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ·  ·*42/\u0026bî^:¿ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆÆÆÆÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ:´-ÊÊÊÊÊÊÖÔ^  ½ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÆÆËÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ· :ëÊÊÊÊÊÊ¬  PÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ   ²ÞÊÊÊÊÝ  WÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÉ    {ÊÊÊÊ² ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÅ   ¹ÊÊÊÊÊ:ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊg  µÊÊÊÊËÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ8·gÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ');\r\ndisp('Is this problem a hair-raiser?');\r\nend\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\n% On request of Ned Gulley, some extra testcases (for the, hopefully, stable voltage regulator within the input voltage range specified on the box).\r\nassert(isequal(transformer(173),115))\r\nassert(isequal(transformer(225),115))\r\nassert(isequal(transformer(145),115))\r\nassert(isequal(transformer(238),115))\r\nassert(isequal(transformer(163),115))\r\nassert(isequal(transformer(128),115))\r\nassert(isequal(transformer(216),115))\r\nassert(isequal(transformer(164),115))\r\nassert(isequal(transformer(136),115))\r\nassert(isequal(transformer(156),115))\r\nassert(isequal(transformer(166),115))\r\nassert(isequal(transformer(132),115))\r\nassert(isequal(transformer(162),115))\r\nassert(isequal(transformer(227),115))\r\nassert(isequal(transformer(203),115))\r\nassert(isequal(transformer(168),115))\r\nassert(isequal(transformer(174),115))\r\nassert(isequal(transformer(170),115))\r\nassert(isequal(transformer(161),115))\r\nassert(isequal(transformer(226),115))\r\nassert(isequal(transformer(232),115))\r\nassert(isequal(transformer(146),115))\r\nassert(isequal(transformer(151),115))\r\nassert(isequal(transformer(152),115))\r\nassert(isequal(transformer(193),115))\r\nassert(isequal(transformer(201),115))\r\nassert(isequal(transformer(192),115))\r\nassert(isequal(transformer(133),115))\r\nassert(isequal(transformer(137),115))\r\nassert(isequal(transformer(224),115))\r\nassert(isequal(transformer(200),115))\r\nassert(isequal(transformer(221),115))\r\nassert(isequal(transformer(160),115))\r\nassert(isequal(transformer(230),115))\r\nassert(isequal(transformer(176),115))\r\nassert(isequal(transformer(210),115))\r\nassert(isequal(transformer(159),115))\r\nassert(isequal(transformer(177),115))\r\nassert(isequal(transformer(126),115))\r\nassert(isequal(transformer(197),115))\r\nassert(isequal(transformer(141),115))\r\nassert(isequal(transformer(222),115))\r\nassert(isequal(transformer(189),115))\r\nassert(isequal(transformer(223),115))\r\nassert(isequal(transformer(140),115))\r\nassert(isequal(transformer(231),115))\r\nassert(isequal(transformer(236),115))\r\nassert(isequal(transformer(180),115))\r\nassert(isequal(transformer(191),115))\r\nassert(isequal(transformer(149),115))\r\nassert(isequal(transformer(172),115))\r\nassert(isequal(transformer(196),115))\r\nassert(isequal(transformer(135),115))\r\nassert(isequal(transformer(209),115))\r\nassert(isequal(transformer(144),115))\r\nassert(isequal(transformer(233),115))\r\nassert(isequal(transformer(215),115))\r\nassert(isequal(transformer(204),115))\r\nassert(isequal(transformer(187),115))\r\nassert(isequal(transformer(202),115))\r\nassert(isequal(transformer(217),115))\r\nassert(isequal(transformer(171),115))\r\nassert(isequal(transformer(153),115))\r\nassert(isequal(transformer(139),115))\r\nassert(isequal(transformer(148),115))\r\nassert(isequal(transformer(169),115))\r\nassert(isequal(transformer(130),115))\r\nassert(isequal(transformer(219),115))\r\nassert(isequal(transformer(206),115))\r\nassert(isequal(transformer(127),115))\r\nassert(isequal(transformer(129),115))\r\nassert(isequal(transformer(218),115))\r\nassert(isequal(transformer(220),115))\r\nassert(isequal(transformer(213),115))\r\nassert(isequal(transformer(207),115))\r\nassert(isequal(transformer(188),115))\r\nassert(isequal(transformer(179),115))\r\nassert(isequal(transformer(185),115))\r\nassert(isequal(transformer(131),115))\r\nassert(isequal(transformer(157),115))\r\nassert(isequal(transformer(143),115))\r\nassert(isequal(transformer(147),115))\r\nassert(isequal(transformer(138),115))\r\nassert(isequal(transformer(214),115))\r\nassert(isequal(transformer(178),115))\r\nassert(isequal(transformer(182),115))\r\nassert(isequal(transformer(195),115))\r\nassert(isequal(transformer(237),115))\r\nassert(isequal(transformer(155),115))\r\nassert(isequal(transformer(158),115))\r\nassert(isequal(transformer(199),115))\r\nassert(isequal(transformer(211),115))\r\nassert(isequal(transformer(228),115))\r\nassert(isequal(transformer(175),115))\r\nassert(isequal(transformer(150),115))\r\nassert(isequal(transformer(194),115))\r\nassert(isequal(transformer(134),115))\r\nassert(isequal(transformer(229),115))\r\nassert(isequal(transformer(181),115))\r\nassert(isequal(transformer(190),115))\r\nassert(isequal(transformer(165),115))\r\nassert(isequal(transformer(235),115))\r\nassert(isequal(transformer(239),115))\r\nassert(isequal(transformer(212),115))\r\nassert(isequal(transformer(208),115))\r\nassert(isequal(transformer(142),115))\r\nassert(isequal(transformer(198),115))\r\nassert(isequal(transformer(184),115))\r\nassert(isequal(transformer(240),115))\r\nassert(isequal(transformer(205),115))\r\nassert(isequal(transformer(234),115))\r\nassert(isequal(transformer(186),115))\r\nassert(isequal(transformer(183),115))\r\nassert(isequal(transformer(167),115))\r\nassert(isequal(transformer(154),115))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":6556,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":108,"test_suite_updated_at":"2014-02-26T08:04:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-02-24T15:36:09.000Z","updated_at":"2026-02-18T14:03:38.000Z","published_at":"2014-02-24T15:36: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\u003eThe problem is simple: we have a wall outlet which supplies 230V and an apparatus that requires 115V.\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\u003eSoftware is always cheaper than hardware (well, most of the time), so we solve this with a program, a Matlab function, to be precise.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a program that converts the supplied input voltage to the required output voltage.\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\u003eIf you like this problem, please like it (after solving).\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":3064,"title":"Cycling — Normalized Power","description":"In cycling, a power meter is an indispensable tool to record power output (in Watts) and measure fitness gains and performance metrics. When analyzing the data though, many different workouts can yield approximately the same average power, despite major differences between workouts (e.g., a long steady effort vs. sprints or intervals). Normalized power (NP) is a method to measure the effect of more intense efforts on the overall workout. NP is calculated by the following four steps (from Training and Racing with a Power Meter by Allen and Coggan):\r\n\r\n# Calculate a 30-second rolling average of the power data\r\n# Raise these values to the fourth power\r\n# Average the resulting values\r\n# Take the fourth root of the result\r\n\r\nYou will be provided with the 30-second rolling average power data set (vector). Write a function to return the average power (using the rolling average data) and the normalized power using steps 2–4 above. Round the values to the nearest integer.","description_html":"\u003cp\u003eIn cycling, a power meter is an indispensable tool to record power output (in Watts) and measure fitness gains and performance metrics. When analyzing the data though, many different workouts can yield approximately the same average power, despite major differences between workouts (e.g., a long steady effort vs. sprints or intervals). Normalized power (NP) is a method to measure the effect of more intense efforts on the overall workout. NP is calculated by the following four steps (from Training and Racing with a Power Meter by Allen and Coggan):\u003c/p\u003e\u003col\u003e\u003cli\u003eCalculate a 30-second rolling average of the power data\u003c/li\u003e\u003cli\u003eRaise these values to the fourth power\u003c/li\u003e\u003cli\u003eAverage the resulting values\u003c/li\u003e\u003cli\u003eTake the fourth root of the result\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eYou will be provided with the 30-second rolling average power data set (vector). Write a function to return the average power (using the rolling average data) and the normalized power using steps 2–4 above. Round the values to the nearest integer.\u003c/p\u003e","function_template":"function [P_avg,NP] = cycling_norm_power(power)\r\n\r\nP_avg = 0;\r\n\r\nNP = 0;\r\n\r\nend\r\n","test_suite":"%% steady\r\npower = 200*ones(1,3600);\r\nP_avg_corr = 200;\r\nNP_corr = 200;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% intervals\r\npower = 100*ones(1,60);\r\npower = [power 250*ones(1,240)];\r\npower = [power 100*ones(1,60)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 200;\r\nNP_corr = 227;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% ramped intervals\r\npower = 100*ones(1,30);\r\npower = [power 100:249];\r\npower = [power 250:-1:101];\r\npower = [power 100*ones(1,30)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 163;\r\nNP_corr = 182;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% medium sprints\r\npower = 100*ones(1,170);\r\npower = [power 500*ones(1,20)];\r\npower = [power 100*ones(1,170)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 122;\r\nNP_corr = 244;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% intense sprints\r\npower = 100*ones(1,176);\r\npower = [power 1500*ones(1,8)];\r\npower = [power 100*ones(1,176)];\r\npower = repmat(power,[1,10]);\r\nP_avg_corr = 131;\r\nNP_corr = 579;\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n\r\n%% anti-cheating (random)\r\nind = randi(5);\r\nswitch ind\r\n\tcase 1\r\n\t\tpower = 200*ones(1,3600);\r\n\t\tP_avg_corr = 200;\r\n\t\tNP_corr = 200;\r\n\tcase 2\r\n\t\tpower = 100*ones(1,60);\r\n\t\tpower = [power 250*ones(1,240)];\r\n\t\tpower = [power 100*ones(1,60)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 200;\r\n\t\tNP_corr = 227;\r\n\tcase 3\r\n\t\tpower = 100*ones(1,30);\r\n\t\tpower = [power 100:249];\r\n\t\tpower = [power 250:-1:101];\r\n\t\tpower = [power 100*ones(1,30)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 163;\r\n\t\tNP_corr = 182;\r\n\tcase 4\r\n\t\tpower = 100*ones(1,170);\r\n\t\tpower = [power 500*ones(1,20)];\r\n\t\tpower = [power 100*ones(1,170)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 122;\r\n\t\tNP_corr = 244;\r\n\tcase 5\r\n\t\tpower = 100*ones(1,176);\r\n\t\tpower = [power 1500*ones(1,8)];\r\n\t\tpower = [power 100*ones(1,176)];\r\n\t\tpower = repmat(power,[1,10]);\r\n\t\tP_avg_corr = 131;\r\n\t\tNP_corr = 579;\r\nend\r\n[P_avg,NP] = cycling_norm_power(power);\r\nassert(isequal(P_avg_corr,P_avg))\r\nassert(isequal(NP_corr,NP))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":43,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-05T03:45:47.000Z","updated_at":"2026-03-31T11:12:20.000Z","published_at":"2015-03-05T03:45:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn cycling, a power meter is an indispensable tool to record power output (in Watts) and measure fitness gains and performance metrics. When analyzing the data though, many different workouts can yield approximately the same average power, despite major differences between workouts (e.g., a long steady effort vs. sprints or intervals). Normalized power (NP) is a method to measure the effect of more intense efforts on the overall workout. NP is calculated by the following four steps (from Training and Racing with a Power Meter by Allen and Coggan):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate a 30-second rolling average of the power data\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRaise these values to the fourth power\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAverage the resulting values\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTake the fourth root of the result\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be provided with the 30-second rolling average power data set (vector). Write a function to return the average power (using the rolling average data) and the normalized power using steps 2–4 above. Round the values to the nearest 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":1441,"title":"Convolution Power","description":"Create the convolution-power vector from initial vector _x_ and power _n_.  In other words, similar to the scalar case, raising to the _n_-th power means repeating the convolution on itself _n_ times. \r\n\r\nAssume that _n_ is a non-negative integer and _x_ is a row vector.\r\n\r\n*Examples*:\r\n\r\n convpower(1:5,0)\r\n ans =\r\n     1\r\n\r\n convpower(1:5,1)\r\n ans = \r\n     1     2     3     4     5\r\n\r\n convpower(1:5,2)\r\n ans = \r\n     1     4    10    20    35    44    46    40    25\r\n\r\nNeither *string operations* nor *interpolations* are allowed!\r\n","description_html":"\u003cp\u003eCreate the convolution-power vector from initial vector \u003ci\u003ex\u003c/i\u003e and power \u003ci\u003en\u003c/i\u003e.  In other words, similar to the scalar case, raising to the \u003ci\u003en\u003c/i\u003e-th power means repeating the convolution on itself \u003ci\u003en\u003c/i\u003e times.\u003c/p\u003e\u003cp\u003eAssume that \u003ci\u003en\u003c/i\u003e is a non-negative integer and \u003ci\u003ex\u003c/i\u003e is a row vector.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e:\u003c/p\u003e\u003cpre\u003e convpower(1:5,0)\r\n ans =\r\n     1\u003c/pre\u003e\u003cpre\u003e convpower(1:5,1)\r\n ans = \r\n     1     2     3     4     5\u003c/pre\u003e\u003cpre\u003e convpower(1:5,2)\r\n ans = \r\n     1     4    10    20    35    44    46    40    25\u003c/pre\u003e\u003cp\u003eNeither \u003cb\u003estring operations\u003c/b\u003e nor \u003cb\u003einterpolations\u003c/b\u003e are allowed!\u003c/p\u003e","function_template":"function y = convpower(x,n)\r\n  y = x;\r\nend","test_suite":"%%\r\nuser_solution = fileread('convpower.m');\r\nassert(isempty(strfind(user_solution,'regexp')));\r\nassert(isempty(strfind(user_solution,'2str')));\r\nassert(isempty(strfind(user_solution,'str2')));\r\nassert(isempty(strfind(user_solution,'interp')));\r\nassert(isempty(strfind(user_solution,'printf')));\r\nassert(isempty(strfind(user_solution,'assert')));\r\n\r\n%%\r\nx = [1 2 3];\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [3 8 1 2 3];\r\nn = 1;\r\ny_correct = [3 8 1 2 3];\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [3 8 1 2 3];\r\nn = 3;\r\ny_correct = [27   216   603   710   570   876   763   354   390   260    63    54    27];\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [1 3 2];\r\nn = 2;\r\ny_correct = [ 1     6    13    12     4];\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [1 1];\r\nn = 10;\r\ny_correct = [ 1    10    45   120   210   252   210   120    45    10     1]\r\nassert(isequal(convpower(x,n),y_correct))\r\n\r\n%%\r\nx = [1 5 2];\r\nn = 7;\r\ny_correct = [1          35         539        4795       27209      102725      261905      451225      523810      410900      217672 76720       17248        2240         128]\r\nassert(isequal(convpower(x,n),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":10352,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":"2013-04-28T07:05:45.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-04-22T11:04:39.000Z","updated_at":"2026-03-11T08:30:52.000Z","published_at":"2013-04-22T11:07:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate the convolution-power vector from initial vector\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 and power\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. In other words, similar to the scalar case, raising to 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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e-th power means repeating the convolution on itself\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 times.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAssume that\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 is a non-negative integer and\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 is a row 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ convpower(1:5,0)\\n ans =\\n     1\\n\\n convpower(1:5,1)\\n ans = \\n     1     2     3     4     5\\n\\n convpower(1:5,2)\\n ans = \\n     1     4    10    20    35    44    46    40    25]]\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\u003eNeither\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estring operations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e nor\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003einterpolations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e are allowed!\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":1786,"title":"Create an index-powered vector","description":"Given a input vector x, return y as index-powered vector as shown below.\r\n\r\nExample\r\n\r\n x = [2 3 6 9]\r\n\r\nthen y should be \r\n\r\n [2^1 3^2 6^3 9^4] = [2 9 216 6561]\r\n","description_html":"\u003cp\u003eGiven a input vector x, return y as index-powered vector as shown below.\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre\u003e x = [2 3 6 9]\u003c/pre\u003e\u003cp\u003ethen y should be\u003c/p\u003e\u003cpre\u003e [2^1 3^2 6^3 9^4] = [2 9 216 6561]\u003c/pre\u003e","function_template":"function y = index_power(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [2 3 6 9];\r\ny_correct = [2 9 216 6561];\r\nassert(isequal(index_power(x),y_correct))\r\n\r\n%%\r\nx = [1 5 11 0 -3 -6];\r\ny_correct = [1  25 1331 0 -243 46656];\r\nassert(isequal(index_power(x),y_correct))\r\n\r\n%%\r\nx = [0 8 -12 0 -8 -2];\r\ny_correct = [0 64 -1728 0 -32768 64];\r\nassert(isequal(index_power(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":8,"comments_count":1,"created_by":16381,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":944,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":13,"created_at":"2013-08-12T02:52:55.000Z","updated_at":"2026-04-08T14:23:38.000Z","published_at":"2013-08-12T02:54:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 input vector x, return y as index-powered vector as shown below.\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[ x = [2 3 6 9]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen y should be\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[ [2^1 3^2 6^3 9^4] = [2 9 216 6561]]]\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":60992,"title":"find powers of two","description":"find the unique, non-repeating, powers of 2 that sum to a given non-zero integer, n\r\n\r\nexample:\r\nn = 23\r\nresult = [1 2 4 16]\r\n\r\nthe result does not need to be in any specific order","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: 201px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 100.5px; transform-origin: 408px 100.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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 254.392px 8px; transform-origin: 254.392px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003efind the unique, non-repeating, powers of 2 that sum to a given non-zero integer, n\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 28.4px 8px; transform-origin: 28.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eexample:\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 19.65px 8px; transform-origin: 19.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003en = 23\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 54.2583px 8px; transform-origin: 54.2583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eresult = [1 2 4 16]\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 0px 8px; transform-origin: 0px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e\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: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 156.758px 8px; transform-origin: 156.758px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethe result does not need to be in any specific order\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = powersOfTwo(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nx = 24;\r\ny_correct = [8 16];\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 63;\r\ny_correct = [1 2 4 8 16 32];\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 999;\r\ny_correct = [1     2     4    32    64   128   256   512];\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))\r\n\r\n%%\r\nx = 16;\r\ny_correct = 16;\r\nassert(isequal(sort(powersOfTwo(x)),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":4925929,"edited_by":4925929,"edited_at":"2025-08-27T19:45:31.000Z","deleted_by":null,"deleted_at":null,"solvers_count":16,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2025-08-27T19:44:27.000Z","updated_at":"2026-03-04T12:26:58.000Z","published_at":"2025-08-27T19:45:31.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\u003efind the unique, non-repeating, powers of 2 that sum to a given non-zero integer, n\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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\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\u003en = 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\u003eresult = [1 2 4 16]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethe result does not need to be in any specific order\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":2431,"title":"Power Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\r\n\r\n - equation written forward, \"=\" doesn't coincide with \":\" --\u003e add 1 to output (e.g., 2:38)\r\n\r\n - equation written forward, \"=\" does coincide with \":\" -- \u003e add 100 to output (e.g., 8:23)\r\n\r\n - equation written backward, \"=\" doesn't coincide with \":\" --\u003e add 10 to output (e.g., 3:28)\r\n\r\n - equation written backward, \"=\" does coincide with \":\" --\u003e add 1000 to output (e.g., 9:23)\r\n\r\nExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day Problem 2433\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\u003c/p\u003e\u003cpre\u003e - equation written forward, \"=\" doesn't coincide with \":\" --\u0026gt; add 1 to output (e.g., 2:38)\u003c/pre\u003e\u003cpre\u003e - equation written forward, \"=\" does coincide with \":\" -- \u0026gt; add 100 to output (e.g., 8:23)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" doesn't coincide with \":\" --\u0026gt; add 10 to output (e.g., 3:28)\u003c/pre\u003e\u003cpre\u003e - equation written backward, \"=\" does coincide with \":\" --\u0026gt; add 1000 to output (e.g., 9:23)\u003c/pre\u003e\u003cp\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\"\u003eProblem 2433\u003c/a\u003e.\u003c/p\u003e","function_template":"function out = power_time(time)\r\n out = 0;\r\nend","test_suite":"%%\r\ntime = '2:38';\r\ny_correct = 1;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '8:23';\r\ny_correct = 100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '3:28';\r\ny_correct = 10;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '9:23';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '7:22';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:31';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:22';\r\ny_correct = 1100;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '1:02';\r\ny_correct = 1000;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '4:12';\r\ny_correct = 0;\r\nassert(isequal(power_time(time),y_correct))\r\n\r\n%%\r\ntime = '5:15';\r\ny_correct = 1001;\r\nassert(isequal(power_time(time),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":8,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":96,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T18:00:06.000Z","updated_at":"2026-01-15T14:21:57.000Z","published_at":"2014-07-15T18:00:06.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\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:\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[ - equation written forward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 1 to output (e.g., 2:38)\\n\\n - equation written forward, \\\"=\\\" does coincide with \\\":\\\" -- \u003e add 100 to output (e.g., 8:23)\\n\\n - equation written backward, \\\"=\\\" doesn't coincide with \\\":\\\" --\u003e add 10 to output (e.g., 3:28)\\n\\n - equation written backward, \\\"=\\\" does coincide with \\\":\\\" --\u003e add 1000 to output (e.g., 9:23)]]\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\u003eExamples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=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\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2433-consecutive-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2433\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"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":42454,"title":"Divisible by n, prime divisors (including powers)","description":"For this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\r\n\r\n  n = 1:10;\r\n  n_p = [2 3 4 5 7 8 9];\r\n\r\nSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors Divisible by n, prime vs. composite divisors\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19 Divisible by n, prime divisors - 11, 13, 17, \u0026 19\u003e.","description_html":"\u003cp\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 1:10;\r\nn_p = [2 3 4 5 7 8 9];\r\n\u003c/pre\u003e\u003cp\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\u003c/p\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\"\u003eDivisible by n, prime vs. composite divisors\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\"\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026 19\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_p] = prime_divisors_incl_powers(n)\r\n\r\nn_p = 1;\r\n\r\nend","test_suite":"%%\r\nn = 1:10;\r\nn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = [2:7 12:17 10 42:55 11 19:29];\r\nn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1:100;\r\nn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 41:59;\r\nn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 100:200;\r\nn_p = [101 103 107 109 113 121 125 127 128 131 137 139 149 151 157 163 167 169 173 179 181 191 193 197 199]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%%\r\nn = 1000:1111;\r\nn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:10;\r\n\t\tn_p = [2 3 4 5 7 8 9]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 3\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 1:100;\r\n\t\tn_p = [2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97]; %prime factors (including powers)\r\n\tcase 2\r\n\t\tn = [2:7 12:17 10 42:55 11 19:29];\r\n\t\tn_p = [2 3 4 5 7 11 13 16 17 19 23 25 27 29 43 47 49 53];\r\n\tcase 3\r\n\t\tn = 41:59;\r\n\t\tn_p = [41 43 47 49 53 59]; %prime factors (including powers)\r\n\tcase 4\r\n\t\tn = 1000:1111;\r\n\t\tn_p = [1009 1013 1019 1021 1024 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109]; %prime factors (including powers)\r\nend\r\nassert(isequal(n_p,prime_divisors_incl_powers(n)))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":95,"test_suite_updated_at":"2017-03-20T19:03:08.000Z","rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:55:28.000Z","updated_at":"2026-01-11T12:28:45.000Z","published_at":"2015-07-09T01:55: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\u003eFor this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:\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[n = 1:10;\\nn_p = [2 3 4 5 7 8 9];]]\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\u003eSince the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42453-divisible-by-n-prime-vs-composite-divisors\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime vs. composite divisors\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42455-divisible-by-n-prime-divisors-11-13-17-19\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors - 11, 13, 17, \u0026amp; 19\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"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":42453,"title":"Divisible by n, prime vs. composite divisors","description":"In general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\r\n\r\n  n = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\n  n = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\n  n = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\n  n = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\n  n = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\n  n = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\n  n = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\n  n = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\n  n = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\n  n = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\r\n\r\nPrevious problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16 divisible by 16\u003e. Next problem: \u003chttp://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers Divisible by n, prime divisors (including powers)\u003e.","description_html":"\u003cp\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003en = 11  |  n_type = 1 (prime)        |  hpf = [11]\r\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\r\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\r\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\r\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\r\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\r\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\r\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\r\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\r\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])\r\n\u003c/pre\u003e\u003cp\u003ePrevious problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\"\u003edivisible by 16\u003c/a\u003e. Next problem: \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\"\u003eDivisible by n, prime divisors (including powers)\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n_type,hpf] = composite_vs_prime_divisor(n)\r\n\r\nn_type = 1;\r\nhpf = [1];\r\n\r\nend\r\n","test_suite":"%%\r\nn = 5;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 5;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 7;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 7;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 15;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,5];\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 25;\r\ntf_corr = 2; %composite factor, prime power (5^2)\r\nhpf_corr = 25;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 125;\r\ntf_corr = 2; %composite factor, prime power (5^3)\r\nhpf_corr = 125;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 20;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [4,5];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 42;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,3,7];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 18;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [2,9];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 29;\r\ntf_corr = 1; %prime factor\r\nhpf_corr = 29;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 39;\r\ntf_corr = 3; %composite factor\r\nhpf_corr = [3,13];\r\n[tf,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(tf,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 64;\r\ntf_corr = 2; %composite factor, prime power (2^6)\r\nhpf_corr = 64;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%%\r\nn = 27;\r\ntf_corr = 2; %composite factor, prime power (3^3)\r\nhpf_corr = 27;\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 29;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 29;\r\n\tcase 2\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 64;\r\n\t\ttf_corr = 2; %composite factor, prime power (2^6)\r\n\t\thpf_corr = 64;\r\n\tcase 2\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\n\tcase 3\r\n\t\tn = 42;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,3,7];\r\n\tcase 4\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n\r\n%% anti-cheating test case\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tn = 39;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [3,13];\r\n\tcase 2\r\n\t\tn = 5;\r\n\t\ttf_corr = 1; %prime factor\r\n\t\thpf_corr = 5;\r\n\tcase 3\r\n\t\tn = 18;\r\n\t\ttf_corr = 3; %composite factor\r\n\t\thpf_corr = [2,9];\r\n\tcase 4\r\n\t\tn = 27;\r\n\t\ttf_corr = 2; %composite factor, prime power (3^3)\r\n\t\thpf_corr = 27;\r\nend\r\n[n_type,hpf] = composite_vs_prime_divisor(n);\r\nassert(isequal(n_type,tf_corr))\r\nassert(isequal(hpf,hpf_corr))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":113,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":22,"created_at":"2015-07-09T01:29:13.000Z","updated_at":"2026-01-11T11:07:59.000Z","published_at":"2015-07-09T01:29:13.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\u003eIn general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:\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[n = 11  |  n_type = 1 (prime)        |  hpf = [11]\\nn = 31  |  n_type = 1 (prime)        |  hpf = [31]\\nn = 9   |  n_type = 2 (prime power)  |  hpf = [9] (3^2)\\nn = 32  |  n_type = 2 (prime power)  |  hpf = [32] (2^5)\\nn = 49  |  n_type = 2 (prime power)  |  hpf = [49] (7^2)\\nn = 21  |  n_type = 3 (composite)    |  hpf = [3,7]\\nn = 39  |  n_type = 3 (composite)    |  hpf = [3,13]\\nn = 42  |  n_type = 3 (composite)    |  hpf = [2,3,7]\\nn = 63  |  n_type = 3 (composite)    |  hpf = [9,7] ([3^2,7])\\nn = 90  |  n_type = 3 (composite)    |  hpf = [2,9,5] ([2,3^2,5])]]\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\u003ePrevious problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42418-divisible-by-16\\\"\u003e\u003cw:r\u003e\u003cw:t\u003edivisible by 16\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/42454-divisible-by-n-prime-divisors-including-powers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDivisible by n, prime divisors (including powers)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"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":44344,"title":"The 5th Root","description":"Write a function to find the 5th root of a number.\r\n\r\nIt sounds easy, but the typical functions are not allowed (see the test suite), so you'll need to find a non-standard method to solve the problem.","description_html":"\u003cp\u003eWrite a function to find the 5th root of a number.\u003c/p\u003e\u003cp\u003eIt sounds easy, but the typical functions are not allowed (see the test suite), so you'll need to find a non-standard method to solve the problem.\u003c/p\u003e","function_template":"function f = fifth_root(n)\r\n f = n^(1/5)\r\nend","test_suite":"%%\r\nfiletext = fileread('fifth_root.m');\r\nassert(isempty(strfind(filetext, '^')),'^ forbidden')\r\nassert(isempty(strfind(filetext, 'power')),'power() forbidden')\r\nassert(isempty(strfind(filetext, 'mpower')),'mpower() forbidden')\r\nassert(isempty(strfind(filetext, 'realpow')),'realpow() forbidden')\r\nassert(isempty(strfind(filetext, 'nthroot')),'nthroot() forbidden')\r\nassert(isempty(strfind(filetext, 'roots')),'roots() forbidden')\r\n\r\n%%\r\nn = 1/9765625;\r\nassert(abs(fifth_root(n)-1/25)\u003c1e-5)\r\n\r\n%%\r\nn = 1/5555;\r\nassert(abs(fifth_root(n)-0.178263811215444)\u003c1e-5)\r\n\r\n%%\r\nn = 1/3125;\r\nassert(abs(fifth_root(n)-1/5)\u003c1e-5)\r\n\r\n%%\r\nn = 1/125;\r\nassert(abs(fifth_root(n)-0.380730787743176)\u003c1e-5)\r\n\r\n%%\r\nn = 1/5;\r\nassert(abs(fifth_root(n)-0.724779663677696)\u003c1e-5)\r\n\r\n%%\r\nn = 1;\r\nassert(abs(fifth_root(n)-1)\u003c1e-5)\r\n\r\n%%\r\nn = 5;\r\nassert(abs(fifth_root(n)-1.37972966146121)\u003c1e-5)\r\n\r\n%%\r\nn = 25;\r\nassert(abs(fifth_root(n)-1.90365393871588)\u003c1e-5)\r\n\r\n%%\r\nn = 50;\r\nassert(abs(fifth_root(n)-2.18672414788656)\u003c1e-5)\r\n\r\n%%\r\nn = 500;\r\nassert(abs(fifth_root(n)-3.46572421577573)\u003c1e-5)\r\n\r\n%%\r\nn = 3125;\r\nassert(abs(fifth_root(n)-5)\u003c1e-5)\r\n\r\n%%\r\nn = 759375;\r\nassert(abs(fifth_root(n)-15)\u003c1e-5)\r\n\r\n%%\r\nn = 9765625;\r\nassert(abs(fifth_root(n)-25)\u003c1e-5)\r\n\r\n%%\r\nn = 312500000;\r\nassert(abs(fifth_root(n)-50)\u003c1e-5)\r\n\r\n%%\r\nn = 75937500000;\r\nassert(abs(fifth_root(n)-150)\u003c1e-5)\r\n\r\n%%\r\nn = 31250000000000;\r\nassert(abs(fifth_root(n)-500)\u003c1e-5)\r\n\r\n%%\r\nn = 52658067346875;\r\nassert(abs(fifth_root(n)-555)\u003c1e-5)","published":true,"deleted":false,"likes_count":13,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":559,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-09-22T16:03:40.000Z","updated_at":"2026-02-03T09:23:18.000Z","published_at":"2017-10-16T01:50:59.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\u003eWrite a function to find the 5th root of a 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\u003eIt sounds easy, but the typical functions are not allowed (see the test suite), so you'll need to find a non-standard method to solve the problem.\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":2396,"title":"last n digit of a power function","description":"Calculate the power of a given a base, exponent. Return the last n digit number.\r\n\r\n  Example 1:\r\n  base = 3; expo = 8; n = 3;\r\n  3^8 = 6561\r\n  return the last 3 digit number 561.\r\n\r\n  Example 2:\r\n  base = 3; expo = 10; n = 3;\r\n  3^10 = 59049\r\n  return the last 3 digit number 49.\r\n\r\n* base, exponent and n are natural numbers","description_html":"\u003cp\u003eCalculate the power of a given a base, exponent. Return the last n digit number.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eExample 1:\r\nbase = 3; expo = 8; n = 3;\r\n3^8 = 6561\r\nreturn the last 3 digit number 561.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eExample 2:\r\nbase = 3; expo = 10; n = 3;\r\n3^10 = 59049\r\nreturn the last 3 digit number 49.\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003ebase, exponent and n are natural numbers\u003c/li\u003e\u003c/ul\u003e","function_template":"function res = lastndigit(base,expo,n)\r\n  res = n;\r\nend","test_suite":"%%\r\nbase = 3; expo = 8; n = 2;\r\ny_correct = 61;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n\r\n%%\r\nbase = 7; expo = 12; n  = 5;\r\ny_correct = 87201;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n\r\n%%\r\nbase = 25; expo = 71; n = 15;\r\ny_correct = 896881103515625;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n\r\n%%\r\nbase = 768; expo = 1579; n = 22;\r\ny_correct = 3750595090000885317632;\r\nassert(isequal(lastndigit(base,expo,n),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":27005,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-06-30T16:29:27.000Z","updated_at":"2014-06-30T16:32:13.000Z","published_at":"2014-06-30T16:31: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\",\"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\u003eCalculate the power of a given a base, exponent. Return the last n digit number.\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[Example 1:\\nbase = 3; expo = 8; n = 3;\\n3^8 = 6561\\nreturn the last 3 digit number 561.\\n\\nExample 2:\\nbase = 3; expo = 10; n = 3;\\n3^10 = 59049\\nreturn the last 3 digit number 49.]]\u003e\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\u003ebase, exponent and n are natural numbers\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":2433,"title":"Consecutive Equation Times (of the day)","description":"Many times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\r\n\r\nFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\r\n\r\nThis problem is related to \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day Problem 2431\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day  Problem 2432\u003e.","description_html":"\u003cp\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/p\u003e\u003cp\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\"\u003eProblem 2431\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\"\u003eProblem 2432\u003c/a\u003e.\u003c/p\u003e","function_template":"function [t_s,num] = equation_times_run(times)\r\n t_s = '0:00';\r\n num = 0;\r\nend","test_suite":"%%\r\ntimes = {'1:00' '1:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'2:07' '2:29'};\r\ny_correct = ['2:11' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'3:03' '4:04'};\r\ny_correct = ['3:11' 4];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '7:11'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'7:17' '9:00'};\r\ny_correct = ['8:17' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'5:55' '9:00'};\r\ny_correct = ['6:15' 3];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))\r\n\r\n%%\r\ntimes = {'1:00' '9:59'};\r\ny_correct = ['1:00' 24];\r\n[t_s,num] = equation_times_run(times);\r\nassert(isequal([t_s,num],y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2014-07-15T19:39:50.000Z","updated_at":"2026-01-15T14:27:21.000Z","published_at":"2014-07-15T19:39:50.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMany times throughout the day can represent mathematical equations. In this problem, we focus on the largest consecutive run of equation times that include one of the four basic operations (+,-,*,/) or the power operator (^). Find the largest such consecutive run for a given range of input times (based on three-digit 12-hour times, 1:00 to 9:59). Return the first time stamp (string) and the number of consecutive points (integer, inclusive) for the maximum run (the first run if there is a tie).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, in the 2:07 to 2:29 time range, the answer is ['2:11' 3] since 2:10 has no equation, 2/1=1 (2:11), 2*1=2 (2:12), 2+1=3 (2:13) and 2:14 has no equation, and there are no such runs of four in that range.\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\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2431-power-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2431\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2432-equation-times-of-the-day\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2432\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"power\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"power\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"power\"","","\"","power","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f64e7aaab60\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f64e7aaaac0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f64e7aa9c60\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f64e7aab1a0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f64e7aaad40\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f64e7aaaca0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f64e7aaac00\u003e":"tag:\"power\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f64e7aaac00\u003e":"tag:\"power\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"power\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"power\"","","\"","power","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f64e7aaab60\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f64e7aaaac0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f64e7aa9c60\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f64e7aab1a0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f64e7aaad40\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f64e7aaaca0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f64e7aaac00\u003e":"tag:\"power\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f64e7aaac00\u003e":"tag:\"power\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2166,"difficulty_rating":"easy"},{"id":3065,"difficulty_rating":"easy"},{"id":45593,"difficulty_rating":"easy"},{"id":1858,"difficulty_rating":"easy"},{"id":2215,"difficulty_rating":"easy"},{"id":3064,"difficulty_rating":"easy"},{"id":1441,"difficulty_rating":"easy"},{"id":1786,"difficulty_rating":"easy-medium"},{"id":60992,"difficulty_rating":"easy-medium"},{"id":2431,"difficulty_rating":"easy-medium"},{"id":42454,"difficulty_rating":"easy-medium"},{"id":42453,"difficulty_rating":"easy-medium"},{"id":44344,"difficulty_rating":"medium"},{"id":2396,"difficulty_rating":"medium"},{"id":2433,"difficulty_rating":"medium-hard"}]}}