{"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":44369,"title":"Circle/Pentagon Overlap","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\u003c/p\u003e","function_template":"function y = circle_pentagon_overlap(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 4;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 15;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0.75];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [7.5,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,-5];\r\nr = 9;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19,8];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 6.6;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 7;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))","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":327,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T18:44:43.000Z","updated_at":"2026-03-18T12:46:34.000Z","published_at":"2017-10-16T01:45: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\",\"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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\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":44358,"title":"I Plead the Fifth","description":"Write a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.","description_html":"\u003cp\u003eWrite a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.\u003c/p\u003e","function_template":"function answer = I_plead_the_fifth(question)\r\n str = 'yes/no';\r\nend","test_suite":"%%\r\nquestion = 'Are you the fifth child?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Were you at home on the night of 24 Oct 1974?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Did you go to work on 15 Oct 1955?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Did you go to the bowling alley last week?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you like bread?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Are there five fingers on your right hand?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you like pumpkins?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you have fifteen siblings?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do two quarters equal fifty cents?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you own five dogs?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Is my name Harry?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":427,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-03T17:12:42.000Z","updated_at":"2026-03-22T03:30:09.000Z","published_at":"2017-10-16T01:45: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\",\"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 provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.\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":44360,"title":"Pentagonal Numbers","description":"Your function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\r\n\r\n [p,d] = pentagonal_numbers(10,40)\r\n\r\nshould return\r\n\r\n p = [12,22,35]\r\n d = [ 0, 0, 1]","description_html":"\u003cp\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\u003c/p\u003e\u003cpre\u003e [p,d] = pentagonal_numbers(10,40)\u003c/pre\u003e\u003cp\u003eshould return\u003c/p\u003e\u003cpre\u003e p = [12,22,35]\r\n d = [ 0, 0, 1]\u003c/pre\u003e","function_template":"function [p,d] = pentagonal_numbers(10,40)\r\n p = [5];\r\n d = [1];\r\nend","test_suite":"%%\r\nx1 = 1; x2 = 25;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22]))\r\nassert(isequal(d,[0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 4;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,1))\r\nassert(isequal(d,0))\r\n\r\n%%\r\nx1 = 10; x2 = 40;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35]))\r\nassert(isequal(d,[0,0,1]))\r\n\r\n%%\r\nx1 = 10; x2 = 99;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35,51,70,92]))\r\nassert(isequal(d,[0,0,1,0,1,0]))\r\n\r\n%%\r\nx1 = 100; x2 = 999;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 40; x2 = 50;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isempty(p))\r\nassert(isempty(d))\r\n\r\n%%\r\nx1 = 1000; x2 = 1500;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1001,1080,1162,1247,1335,1426]))\r\nassert(isequal(d,[0,1,0,0,1,0]))\r\n\r\n%%\r\nx1 = 1500; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22,35,51,70,92,117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925,1001,1080,1162,1247,1335,1426,1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 10000; x2 = 12000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[10045,10292,10542,10795,11051,11310,11572,11837]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 100000; x2 = 110000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[100492,101270,102051,102835,103622,104412,105205,106001,106800,107602,108407,109215]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 1000000; x2 = 1010101;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1000825,1003277,1005732,1008190]))\r\nassert(isequal(d,[1,0,0,1]))","published":true,"deleted":false,"likes_count":12,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":677,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-05T17:43:36.000Z","updated_at":"2026-03-18T12:42:40.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. 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[ [p,d] = pentagonal_numbers(10,40)]]\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\u003eshould return\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[ p = [12,22,35]\\n d = [ 0, 0, 1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44368,"title":"Inscribed Pentagon?","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\r\n\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0: the pentagon is completely enclosed within the circle but is not inscribed\r\n1: the pentagon is inscribed in the circle (within ±0.02)\r\n2: the vertices of the pentagon extend beyond the circle\r\n\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\u003c/p\u003e","function_template":"function y = inscribed_pentagon(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),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":306,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T16:31:01.000Z","updated_at":"2026-03-18T12:45:42.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\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[0: the pentagon is completely enclosed within the circle but is not inscribed\\n1: the pentagon is inscribed in the circle (within ±0.02)\\n2: the vertices of the pentagon extend beyond the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\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":44305,"title":"5 Prime Numbers","description":"Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\r\n\r\nFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\r\n\r\n p = [61,67,71,73,79, ... 149,151,157,163, ... 241,251,257,263, ... 349,353,359,367, ... 983,991,997]\r\n\r\nThis set contains at least five numbers that contain a five; the first five are:\r\n\r\n p5 = [151,157,251,257,353]\r\n\r\nwhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 420.4375px 118px; vertical-align: baseline; perspective-origin: 420.4375px 118px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 31.5px; white-space: pre-wrap; perspective-origin: 309px 31.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p = [61,67,71,73,79, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e149,151,157,163, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e241,251,257,263, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e349,353,359,367, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e983,991,997]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p5 = [151,157,251,257,353]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 21px; white-space: pre-wrap; perspective-origin: 309px 21px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = five_primes(n_min,n_max)\r\n  y = [];\r\nend","test_suite":"%%\r\nn_min = 60;\r\nn_max = 1000;\r\ny_correct = [151,157,251,257,353];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 60;\r\nn_max = 300;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 200;\r\ny_correct = [5,53,59,151,157];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 100;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 600;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 555;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 500000000;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5020;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5200;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 55555555;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 55555;\r\nn_max = 56789;\r\ny_correct = [55579,55589,55603,55609,55619];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 987654321;\r\nn_max = 988777666;\r\ny_correct = [987654323,987654337,987654347,987654359,987654361];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":453,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T18:33:05.000Z","updated_at":"2026-04-06T09:57:52.000Z","published_at":"2017-10-16T01:45:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\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[ p = [61,67,71,73,79, … 149,151,157,163, … 241,251,257,263, … 349,353,359,367, … 983,991,997]]]\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\u003eThis set contains at least five numbers that contain a five; the first five are:\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[ p5 = [151,157,251,257,353]]]\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\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\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":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":44367,"title":"Inscribed Pentagon? 2","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon may or may not be centered on the circle. The function should return one of the following values:\r\n\r\n -1: the pentagon is not centered on the circle (within 5% of r)^\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples. (There will not be a case where some vertices are within the circle and others without.)\r\n\r\n^ Due to the asymmetric nature of the pentagon, its centroid does not coincide with center of its inscribing circle, hence the ±5% tolerance window. ","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon may or may not be centered on the circle. The function should return one of the following values:\u003c/p\u003e\u003cpre\u003e -1: the pentagon is not centered on the circle (within 5% of r)^\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples. (There will not be a case where some vertices are within the circle and others without.)\u003c/p\u003e\u003cp\u003e^ Due to the asymmetric nature of the pentagon, its centroid does not coincide with center of its inscribing circle, hence the ±5% tolerance window.\u003c/p\u003e","function_template":"function y = inscribed_pentagon2(p,cp,r)\r\n y = -1;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0.5];\r\nr = 8.75;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [1.98,-0.47];\r\nr = 8.75;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp_temp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp_temp,[5,1]);\r\ncp = [19.5,9.08];\r\nr = 2.5;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp_temp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp_temp,[5,1]);\r\ncp = [19.86,7.19];\r\nr = 7.5;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.41,29.04];\r\nr = 6.13;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [27.07,27.66];\r\nr = 9.63;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),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":88,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-10T15:28:54.000Z","updated_at":"2026-04-02T01:39:53.000Z","published_at":"2017-10-16T01:51:00.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon may or may not be centered on the circle. The function should return one of the following values:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ -1: the pentagon is not centered on the circle (within 5% of r)^\\n  0: the pentagon is completely enclosed within the circle but is not inscribed\\n  1: the pentagon is inscribed in the circle (within ±0.02)\\n  2: the vertices of the pentagon extend beyond the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples. (There will not be a case where some vertices are within the circle and others without.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e^ Due to the asymmetric nature of the pentagon, its centroid does not coincide with center of its inscribing circle, hence the ±5% tolerance window.\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":44359,"title":"5th Time's a Charm","description":"Write a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\r\n\r\nFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.","description_html":"\u003cp\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\u003c/p\u003e\u003cp\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\u003c/p\u003e","function_template":"function y = fifth_times_a_charm(x)\r\n y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = -1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = 42;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = i;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))","published":true,"deleted":false,"likes_count":7,"comments_count":5,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":193,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-03T17:35:55.000Z","updated_at":"2026-03-13T03:06:49.000Z","published_at":"2017-10-16T01:51:00.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the 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\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\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":44386,"title":"Circumscribed Pentagon?","description":"Building off of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44368 Problem 44368\u003e, your function will be provided with the five vertices of a regular pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return one of the following values:\r\n\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle, but its edges still cross back into the circle\r\n  3: the pentagon circumscribes the circle (within ±0.02)\r\n  4: the pentagon completely encloses, and does not touch, the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples.","description_html":"\u003cp\u003eBuilding off of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44368\"\u003eProblem 44368\u003c/a\u003e, your function will be provided with the five vertices of a regular pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return one of the following values:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0: the pentagon is completely enclosed within the circle but is not inscribed\r\n1: the pentagon is inscribed in the circle (within ±0.02)\r\n2: the vertices of the pentagon extend beyond the circle, but its edges still cross back into the circle\r\n3: the pentagon circumscribes the circle (within ±0.02)\r\n4: the pentagon completely encloses, and does not touch, the circle\r\n\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\u003c/p\u003e","function_template":"function y = circumscribed_pentagon(p,cp,r)\r\n  y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5.61; 5.40,1.69; 3.34,-4.66; -3.34,-4.66; -5.40,1.69];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.18; 5.88,1.91; 3.63,-5.00; -3.63,-5.00; -5.88,1.91];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [20,13.61; 25.40,9.69; 23.34,3.34; 16.66,3.34; 14.60,9.69];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [20,14.18; 25.88,9.91; 23.63,3.00; 16.37,3.00; 14.12,9.91];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 4;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 4;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 4;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [26.97,34.06; 32.37,30.14; 30.31,23.79; 23.63,23.79; 21.57,30.14];\r\ncp = [26.97,28.45];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [31.35,32.83; 32.49,25.64; 26.00,22.34; 20.85,27.48; 24.16,33.97];\r\ncp = [26.97,28.45];\r\nr = 5.01;\r\ny_correct = 3;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":64,"test_suite_updated_at":"2017-12-08T15:45:11.000Z","rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-13T20:03:45.000Z","updated_at":"2025-11-04T13:12:51.000Z","published_at":"2017-10-16T01:51:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44368\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44368\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, your function will be provided with the five vertices of a regular pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return one of the following values:\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[0: the pentagon is completely enclosed within the circle but is not inscribed\\n1: the pentagon is inscribed in the circle (within ±0.02)\\n2: the vertices of the pentagon extend beyond the circle, but its edges still cross back into the circle\\n3: the pentagon circumscribes the circle (within ±0.02)\\n4: the pentagon completely encloses, and does not touch, the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\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":44306,"title":"Is it really a 5?","description":"A number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\r\n\r\n n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\r\n\r\nThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\r\n\r\nSee the test suite for more examples.","description_html":"\u003cp\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\u003c/p\u003e\u003cpre\u003e n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\u003c/pre\u003e\u003cp\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\u003c/p\u003e\u003cp\u003eSee the test suite for more examples.\u003c/p\u003e","function_template":"function tf = is_it_really_a_5(n)\r\n tf = 0;\r\nend","test_suite":"%%\r\nn = 5;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 25;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 35;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 52;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 59;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 85;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 105;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 115;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 125;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 250;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 555;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000; %5,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000; %15,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55555; %55,555\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000; %50,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55000; %55,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50500; %50,500\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050; %50,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50005; %50,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 500000; %500,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000; %5,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000000; %15,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000000; %50,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 105000000; %105,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050050; %50,050,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000005; %50,000,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000015; %50,000,015\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500000000; %500,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000000; %5,000,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000000000; %50,000,000,000\r\nassert(isequal(is_it_really_a_5(n),0))","published":true,"deleted":false,"likes_count":7,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":316,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T22:07:48.000Z","updated_at":"2026-03-18T13:28:44.000Z","published_at":"2017-10-16T01:45: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\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \\\"five\\\" anywhere. 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 = 5; return true since it is spelled \\\"five\\\"\\n n = 15; return false since it is spelled \\\"fifteen\\\" and does not contain the four-letter string \\\"five\\\"]]\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\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \\\"five\\\" for this problem.\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\u003eSee the test suite for more examples.\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":44369,"title":"Circle/Pentagon Overlap","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\u003c/p\u003e","function_template":"function y = circle_pentagon_overlap(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 4;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 15;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [2,0.75];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [7.5,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,-5];\r\nr = 9;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19,8];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 6.6;\r\ny_correct = 4;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [19.5,10];\r\nr = 7;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 5;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8;\r\ny_correct = 0;\r\nassert(isequal(circle_pentagon_overlap(p,cp,r),y_correct))","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":327,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T18:44:43.000Z","updated_at":"2026-03-18T12:46:34.000Z","published_at":"2017-10-16T01:45: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\",\"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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return the number of pentagon vertices that lie within or on the circle. The tolerance for lying on the circle is 0.02.\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":44358,"title":"I Plead the Fifth","description":"Write a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.","description_html":"\u003cp\u003eWrite a function to provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.\u003c/p\u003e","function_template":"function answer = I_plead_the_fifth(question)\r\n str = 'yes/no';\r\nend","test_suite":"%%\r\nquestion = 'Are you the fifth child?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Were you at home on the night of 24 Oct 1974?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Did you go to work on 15 Oct 1955?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Did you go to the bowling alley last week?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you like bread?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Are there five fingers on your right hand?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you like pumpkins?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))\r\n\r\n%%\r\nquestion = 'Do you have fifteen siblings?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do two quarters equal fifty cents?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Do you own five dogs?';\r\nassert(isempty(I_plead_the_fifth(question)))\r\n\r\n%%\r\nquestion = 'Is my name Harry?';\r\nassert(strcmpi(I_plead_the_fifth(question),'yes') || ...\r\n    strcmpi(I_plead_the_fifth(question),'no'))","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":427,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-03T17:12:42.000Z","updated_at":"2026-03-22T03:30:09.000Z","published_at":"2017-10-16T01:45: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\",\"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 provide a yes or no answer to the input string. However, it must plead the 5th amendment (return an empty string) if the number five or any variation thereof (e.g., fifth, fifty, fifteen, 5) is within the input string.\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":44360,"title":"Pentagonal Numbers","description":"Your function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\r\n\r\n [p,d] = pentagonal_numbers(10,40)\r\n\r\nshould return\r\n\r\n p = [12,22,35]\r\n d = [ 0, 0, 1]","description_html":"\u003cp\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. For example,\u003c/p\u003e\u003cpre\u003e [p,d] = pentagonal_numbers(10,40)\u003c/pre\u003e\u003cp\u003eshould return\u003c/p\u003e\u003cpre\u003e p = [12,22,35]\r\n d = [ 0, 0, 1]\u003c/pre\u003e","function_template":"function [p,d] = pentagonal_numbers(10,40)\r\n p = [5];\r\n d = [1];\r\nend","test_suite":"%%\r\nx1 = 1; x2 = 25;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22]))\r\nassert(isequal(d,[0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 4;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,1))\r\nassert(isequal(d,0))\r\n\r\n%%\r\nx1 = 10; x2 = 40;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35]))\r\nassert(isequal(d,[0,0,1]))\r\n\r\n%%\r\nx1 = 10; x2 = 99;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[12,22,35,51,70,92]))\r\nassert(isequal(d,[0,0,1,0,1,0]))\r\n\r\n%%\r\nx1 = 100; x2 = 999;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 40; x2 = 50;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isempty(p))\r\nassert(isempty(d))\r\n\r\n%%\r\nx1 = 1000; x2 = 1500;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1001,1080,1162,1247,1335,1426]))\r\nassert(isequal(d,[0,1,0,0,1,0]))\r\n\r\n%%\r\nx1 = 1500; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 1; x2 = 3000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1,5,12,22,35,51,70,92,117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925,1001,1080,1162,1247,1335,1426,1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882]))\r\nassert(isequal(d,[0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 10000; x2 = 12000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[10045,10292,10542,10795,11051,11310,11572,11837]))\r\nassert(isequal(d,[1,0,0,1,0,1,0,0]))\r\n\r\n%%\r\nx1 = 100000; x2 = 110000;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[100492,101270,102051,102835,103622,104412,105205,106001,106800,107602,108407,109215]))\r\nassert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1]))\r\n\r\n%%\r\nx1 = 1000000; x2 = 1010101;\r\n[p,d] = pentagonal_numbers(x1,x2)\r\nassert(isequal(p,[1000825,1003277,1005732,1008190]))\r\nassert(isequal(d,[1,0,0,1]))","published":true,"deleted":false,"likes_count":12,"comments_count":3,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":677,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-05T17:43:36.000Z","updated_at":"2026-03-18T12:42:40.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascending order. Additionally, it should return an array that indicates those numbers that are divisible by 5. 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[ [p,d] = pentagonal_numbers(10,40)]]\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\u003eshould return\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[ p = [12,22,35]\\n d = [ 0, 0, 1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44368,"title":"Inscribed Pentagon?","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\r\n\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples.","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0: the pentagon is completely enclosed within the circle but is not inscribed\r\n1: the pentagon is inscribed in the circle (within ±0.02)\r\n2: the vertices of the pentagon extend beyond the circle\r\n\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\u003c/p\u003e","function_template":"function y = inscribed_pentagon(p,cp,r)\r\n y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon(p,cp,r),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":306,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-10-10T16:31:01.000Z","updated_at":"2026-03-18T12:45:42.000Z","published_at":"2017-10-16T01:45: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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon will be centered about the circle. The function should return one of the following values:\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[0: the pentagon is completely enclosed within the circle but is not inscribed\\n1: the pentagon is inscribed in the circle (within ±0.02)\\n2: the vertices of the pentagon extend beyond the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\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":44305,"title":"5 Prime Numbers","description":"Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\r\n\r\nFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\r\n\r\n p = [61,67,71,73,79, ... 149,151,157,163, ... 241,251,257,263, ... 349,353,359,367, ... 983,991,997]\r\n\r\nThis set contains at least five numbers that contain a five; the first five are:\r\n\r\n p5 = [151,157,251,257,353]\r\n\r\nwhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 420.4375px 118px; vertical-align: baseline; perspective-origin: 420.4375px 118px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 31.5px; white-space: pre-wrap; perspective-origin: 309px 31.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p = [61,67,71,73,79, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e149,151,157,163, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e241,251,257,263, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e349,353,359,367, \u003c/span\u003e\u003cspan style=\"border-bottom-color: rgb(255, 0, 0); border-left-color: rgb(255, 0, 0); border-right-color: rgb(255, 0, 0); border-top-color: rgb(255, 0, 0); caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); margin-right: 0px; outline-color: rgb(255, 0, 0); text-decoration-color: rgb(255, 0, 0); column-rule-color: rgb(255, 0, 0); \"\u003e… \u003c/span\u003e\u003cspan style=\"margin-right: 0px; \"\u003e983,991,997]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThis set contains at least five numbers that contain a five; the first five are:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 417.4375px 10px; perspective-origin: 417.4375px 10px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e p5 = [151,157,251,257,353]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 21px; white-space: pre-wrap; perspective-origin: 309px 21px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = five_primes(n_min,n_max)\r\n  y = [];\r\nend","test_suite":"%%\r\nn_min = 60;\r\nn_max = 1000;\r\ny_correct = [151,157,251,257,353];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 60;\r\nn_max = 300;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 200;\r\ny_correct = [5,53,59,151,157];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 1;\r\nn_max = 100;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 600;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 555;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 500;\r\nn_max = 500000000;\r\ny_correct = [503,509,521,523,541];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5020;\r\ny_correct = -1;\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 5200;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 5000;\r\nn_max = 55555555;\r\ny_correct = [5003,5009,5011,5021,5023];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 55555;\r\nn_max = 56789;\r\ny_correct = [55579,55589,55603,55609,55619];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))\r\n\r\n%%\r\nn_min = 987654321;\r\nn_max = 988777666;\r\ny_correct = [987654323,987654337,987654347,987654359,987654361];\r\nassert(isequal(five_primes(n_min,n_max),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":453,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T18:33:05.000Z","updated_at":"2026-04-06T09:57:52.000Z","published_at":"2017-10-16T01:45:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, for n_min = 60 and n_max = 1000, the set of prime numbers is:\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[ p = [61,67,71,73,79, … 149,151,157,163, … 241,251,257,263, … 349,353,359,367, … 983,991,997]]]\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\u003eThis set contains at least five numbers that contain a five; the first five are:\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[ p5 = [151,157,251,257,353]]]\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\u003ewhich is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).\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":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":44367,"title":"Inscribed Pentagon? 2","description":"Your function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon may or may not be centered on the circle. The function should return one of the following values:\r\n\r\n -1: the pentagon is not centered on the circle (within 5% of r)^\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples. (There will not be a case where some vertices are within the circle and others without.)\r\n\r\n^ Due to the asymmetric nature of the pentagon, its centroid does not coincide with center of its inscribing circle, hence the ±5% tolerance window. ","description_html":"\u003cp\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon may or may not be centered on the circle. The function should return one of the following values:\u003c/p\u003e\u003cpre\u003e -1: the pentagon is not centered on the circle (within 5% of r)^\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples. (There will not be a case where some vertices are within the circle and others without.)\u003c/p\u003e\u003cp\u003e^ Due to the asymmetric nature of the pentagon, its centroid does not coincide with center of its inscribing circle, hence the ±5% tolerance window.\u003c/p\u003e","function_template":"function y = inscribed_pentagon2(p,cp,r)\r\n y = -1;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0.5];\r\nr = 8.75;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [1.98,-0.47];\r\nr = 8.75;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp_temp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp_temp,[5,1]);\r\ncp = [19.5,9.08];\r\nr = 2.5;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\ncp_temp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp_temp,[5,1]);\r\ncp = [19.86,7.19];\r\nr = 7.5;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 2;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.41,29.04];\r\nr = 6.13;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [27.07,27.66];\r\nr = 9.63;\r\ny_correct = -1;\r\nassert(isequal(inscribed_pentagon2(p,cp,r),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":88,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-10T15:28:54.000Z","updated_at":"2026-04-02T01:39:53.000Z","published_at":"2017-10-16T01:51:00.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eYour function will be provided with the five vertices of a pentagon (p) as well as the center point (cp) and radius (r) of a circle. The pentagon may or may not be centered on the circle. The function should return one of the following values:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ -1: the pentagon is not centered on the circle (within 5% of r)^\\n  0: the pentagon is completely enclosed within the circle but is not inscribed\\n  1: the pentagon is inscribed in the circle (within ±0.02)\\n  2: the vertices of the pentagon extend beyond the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples. (There will not be a case where some vertices are within the circle and others without.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e^ Due to the asymmetric nature of the pentagon, its centroid does not coincide with center of its inscribing circle, hence the ±5% tolerance window.\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":44359,"title":"5th Time's a Charm","description":"Write a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\r\n\r\nFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.","description_html":"\u003cp\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\u003c/p\u003e\u003cp\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\u003c/p\u003e","function_template":"function y = fifth_times_a_charm(x)\r\n y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = -1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = 42;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = i;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))","published":true,"deleted":false,"likes_count":7,"comments_count":5,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":193,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-03T17:35:55.000Z","updated_at":"2026-03-13T03:06:49.000Z","published_at":"2017-10-16T01:51:00.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the 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\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\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":44386,"title":"Circumscribed Pentagon?","description":"Building off of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44368 Problem 44368\u003e, your function will be provided with the five vertices of a regular pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return one of the following values:\r\n\r\n  0: the pentagon is completely enclosed within the circle but is not inscribed\r\n  1: the pentagon is inscribed in the circle (within ±0.02)\r\n  2: the vertices of the pentagon extend beyond the circle, but its edges still cross back into the circle\r\n  3: the pentagon circumscribes the circle (within ±0.02)\r\n  4: the pentagon completely encloses, and does not touch, the circle\r\n\r\nPoints will be rounded to the nearest hundredth. See the test cases for examples.","description_html":"\u003cp\u003eBuilding off of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44368\"\u003eProblem 44368\u003c/a\u003e, your function will be provided with the five vertices of a regular pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return one of the following values:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0: the pentagon is completely enclosed within the circle but is not inscribed\r\n1: the pentagon is inscribed in the circle (within ±0.02)\r\n2: the vertices of the pentagon extend beyond the circle, but its edges still cross back into the circle\r\n3: the pentagon circumscribes the circle (within ±0.02)\r\n4: the pentagon completely encloses, and does not touch, the circle\r\n\u003c/pre\u003e\u003cp\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\u003c/p\u003e","function_template":"function y = circumscribed_pentagon(p,cp,r)\r\n  y = 0;\r\nend","test_suite":"%%\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,5.61; 5.40,1.69; 3.34,-4.66; -3.34,-4.66; -5.40,1.69];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,6.18; 5.88,1.91; 3.63,-5.00; -3.63,-5.00; -5.88,1.91];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44];\r\ncp = [0,0];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,5; 4.76,1.55; 2.94,-4.05; -2.94,-4.05; -4.76,1.55] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [20,13.61; 25.40,9.69; 23.34,3.34; 16.66,3.34; 14.60,9.69];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [20,14.18; 25.88,9.91; 23.63,3.00; 16.37,3.00; 14.12,9.91];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 3;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,6.58; 6.42,1.92; 3.97,-5.63; -3.97,-5.63; -6.42,1.92] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 4;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\ncp = [20,8];\r\np = [0,4.55; 4.28,1.44; 2.65,-3.59; -2.65,-3.59; -4.28,1.44] + repmat(cp,[5,1]);\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.66,11.42; 24.37,5.58; 19.05,3.10; 15.04,7.40; 17.89,12.54];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [25.01,12.47; 25.98,4.58; 18.78,1.23; 13.37,7.03; 17.22,13.97];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 4;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [23.27,11.12; 23.92,5.87; 19.12,3.63; 15.52,7.50; 18.08,12.13];\r\ncp = [20,8];\r\nr = 5;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.94,36.26; 35.61,27.09; 28.34,19.82; 19.17,24.49; 20.78,34.65];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 1;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [32.54,38.78; 38.84,26.41; 29.02,16.59; 16.65,22.89; 18.83,36.61];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 4;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [30.49,35.54; 34.69,27.29; 28.14,20.74; 19.89,24.95; 21.34,34.09];\r\ncp = [26.97,28.45];\r\nr = 8.75;\r\ny_correct = 0;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [26.97,34.06; 32.37,30.14; 30.31,23.79; 23.63,23.79; 21.57,30.14];\r\ncp = [26.97,28.45];\r\nr = 5;\r\ny_correct = 2;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))\r\n\r\n%%\r\np = [31.35,32.83; 32.49,25.64; 26.00,22.34; 20.85,27.48; 24.16,33.97];\r\ncp = [26.97,28.45];\r\nr = 5.01;\r\ny_correct = 3;\r\nassert(isequal(circumscribed_pentagon(p,cp,r),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":64,"test_suite_updated_at":"2017-12-08T15:45:11.000Z","rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-13T20:03:45.000Z","updated_at":"2025-11-04T13:12:51.000Z","published_at":"2017-10-16T01:51:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44368\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44368\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, your function will be provided with the five vertices of a regular pentagon (p) as well as the center point (cp) and radius (r) of a circle. The function should return one of the following values:\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[0: the pentagon is completely enclosed within the circle but is not inscribed\\n1: the pentagon is inscribed in the circle (within ±0.02)\\n2: the vertices of the pentagon extend beyond the circle, but its edges still cross back into the circle\\n3: the pentagon circumscribes the circle (within ±0.02)\\n4: the pentagon completely encloses, and does not touch, the circle]]\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\u003ePoints will be rounded to the nearest hundredth. See the test cases for examples.\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":44306,"title":"Is it really a 5?","description":"A number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\r\n\r\n n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\r\n\r\nThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\r\n\r\nSee the test suite for more examples.","description_html":"\u003cp\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \"five\" anywhere. For example:\u003c/p\u003e\u003cpre\u003e n = 5; return true since it is spelled \"five\"\r\n n = 15; return false since it is spelled \"fifteen\" and does not contain the four-letter string \"five\"\u003c/pre\u003e\u003cp\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \"five\" for this problem.\u003c/p\u003e\u003cp\u003eSee the test suite for more examples.\u003c/p\u003e","function_template":"function tf = is_it_really_a_5(n)\r\n tf = 0;\r\nend","test_suite":"%%\r\nn = 5;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 25;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 35;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 52;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 59;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 85;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 105;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 115;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 125;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 250;\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 555;\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000; %5,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000; %15,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55555; %55,555\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000; %50,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 55000; %55,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50500; %50,500\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050; %50,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50005; %50,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 500000; %500,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000; %5,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 15000000; %15,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000000; %50,000,000\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 105000000; %105,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50050050; %50,050,050\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 50000005; %50,000,005\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000015; %50,000,015\r\nassert(isequal(is_it_really_a_5(n),0))\r\n\r\n%%\r\nn = 500000000; %500,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 5000000000; %5,000,000,000\r\nassert(isequal(is_it_really_a_5(n),1))\r\n\r\n%%\r\nn = 50000000000; %50,000,000,000\r\nassert(isequal(is_it_really_a_5(n),0))","published":true,"deleted":false,"likes_count":7,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":316,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":34,"created_at":"2017-09-08T22:07:48.000Z","updated_at":"2026-03-18T13:28:44.000Z","published_at":"2017-10-16T01:45: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\u003eA number containing at least one five will be passed to your function, which must return true or false depending upon whether the English spelling of the number may contain \\\"five\\\" anywhere. 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 = 5; return true since it is spelled \\\"five\\\"\\n n = 15; return false since it is spelled \\\"fifteen\\\" and does not contain the four-letter string \\\"five\\\"]]\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\u003eThis criterion applies to any common spelling of the number. For example, 1500 can be written fifteen hundred. But, it can also be written one thousand five hundred. So, 1500 would be considered to contain a \\\"five\\\" for this problem.\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\u003eSee the test suite for more examples.\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:\"five\"","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:\"five\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"five\"","","\"","five","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f9c686d5bf8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f9c686d58d8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f9c686d4078\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f9c686d5f18\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f9c686d5e78\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f9c686d5d38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f9c686d5c98\u003e":"tag:\"five\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f9c686d5c98\u003e":"tag:\"five\""},"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:\"five\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"five\"","","\"","five","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f9c686d5bf8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f9c686d58d8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f9c686d4078\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f9c686d5f18\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f9c686d5e78\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f9c686d5d38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f9c686d5c98\u003e":"tag:\"five\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f9c686d5c98\u003e":"tag:\"five\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44369,"difficulty_rating":"easy-medium"},{"id":44358,"difficulty_rating":"easy-medium"},{"id":44360,"difficulty_rating":"easy-medium"},{"id":44368,"difficulty_rating":"easy-medium"},{"id":44305,"difficulty_rating":"easy-medium"},{"id":44344,"difficulty_rating":"medium"},{"id":44367,"difficulty_rating":"medium"},{"id":44359,"difficulty_rating":"medium"},{"id":44386,"difficulty_rating":"medium"},{"id":44306,"difficulty_rating":"medium"}]}}