{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":2530,"title":"Powers Of","description":"Fill the vector with powers of 2, so that vector(1) is 2^1, vector(2) is 2^2, etc. Stop with vector(10).  Complete the function using a *for* loop.","description_html":"\u003cp\u003eFill the vector with powers of 2, so that vector(1) is 2^1, vector(2) is 2^2, etc. Stop with vector(10).  Complete the function using a \u003cb\u003efor\u003c/b\u003e loop.\u003c/p\u003e","function_template":"function vector = PowersOf(vector)\r\n  for ?\r\n    ?\r\n  end\r\nend","test_suite":"%%\r\nvector1 = [0 0 0 0 0 0 0 0 0 0];\r\nvector1_correct = [2 4 8 16 32 64 128 256 512 1024];\r\ncode = textread('PowersOf.m', '%s');\r\nassert(isequal(PowersOf(vector1), vector1_correct) \u0026\u0026 ...\r\n       strcmp(code(5), 'for') \u0026\u0026 ...\r\n       strcmp(code(end-7), 'end') \u0026\u0026 ...\r\n       strcmp(code(end-6), 'end'));","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":24594,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":108,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-26T12:47:32.000Z","updated_at":"2026-03-22T17:55:53.000Z","published_at":"2014-08-26T13:56:12.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\u003eFill the vector with powers of 2, so that vector(1) is 2^1, vector(2) is 2^2, etc. Stop with vector(10). Complete the function using a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efor\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e loop.\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":44521,"title":"Make your own Test Suite (part 3)","description":"In this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to implement a robust Test Suite* to check whether _my_ submitted solutions meet _your_ requirements or not, and to be fairly assured that I am not trying to 'game' the system.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain,   \r\n* *without* using |regexp| or |regexpi| or |ans|, \r\n* *within* less than 0.01 seconds (10 milliseconds).\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour Test Suite (contained within _your_ function |testSuite|) must address each of the elements of your problem specification:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function.  \r\n# Ensure that the returned *data type* is suitable.  \r\n# You *cannot* use (or mention) the functions |sind|, |sin|, |cscd| or |cosd| in your Test Suite;  any other functions are allowed.  [ _MOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!_ ]\r\n# You must check that I *haven't used* \"regexp\" or \"regexpi\" or \"ans\".  You could try using the \u003chttps://au.mathworks.com/help/coursework/ug/assessfunctionabsence.html |assessFunctionAbsence|\u003e function in the form |assessFunctionAbsence(..., 'FileName','SINE.m')|, or else you could try 'manually' opening the file |SINE.m| that corresponds to my submitted solution and then parsing it for occurrence of the prohibited function/variable.  \r\n# You must check that my code returns a result within *less than 0.01 seconds* (for a single input of an arbitrary angle).  You could use \u003chttps://au.mathworks.com/help/matlab/ref/tic.html |tic|\u003e \u0026 \u003chttps://au.mathworks.com/help/matlab/ref/toc.html |toc|\u003e or \u003chttps://au.mathworks.com/help/matlab/ref/timeit.html |timeit|\u003e, or a variety of other MATLAB functions (but not |cputime| in this case).  If your Test Suite claims that my submission runs slowly, then you must be confident that it is truly caused only by inefficiency in my submitted code, *not* just general/erratic overheads in 'queuing' or suchlike on the Cody servers.  \r\n# Your |assert| (or other) function must throw \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e with the following *|error message| text* contents.\r\n\r\n* 'Incorrect value' if the output is too inaccurate.\r\n* 'Incorrect data type' if the output is not appropriate.\r\n* 'Too slow' if my submitted code is too slow.\r\n* 'Banned word' if my submitted code contains the |regexp| or |regexpi| functions or the \u003chttps://au.mathworks.com/help/matlab/ref/ans.html |ans|\u003e variable.  For _this_ infringement, _additional_ text can _also_ (optionally!) be present in the message — for example, 'You cannot do that!  Banned word (regexp/regexpi)' would also be acceptable.\r\n\r\nWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  \r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44631 Problem 44631\u003e (part *0*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44617 Problem 44617\u003e (part *1*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44616 Problem 44616\u003e (part *2*)","description_html":"\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to implement a robust Test Suite\u003c/b\u003e to check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not, and to be fairly assured that I am not trying to 'game' the system.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain,\u003c/li\u003e\u003cli\u003e\u003cb\u003ewithout\u003c/b\u003e using \u003ctt\u003eregexp\u003c/tt\u003e or \u003ctt\u003eregexpi\u003c/tt\u003e or \u003ctt\u003eans\u003c/tt\u003e,\u003c/li\u003e\u003cli\u003e\u003cb\u003ewithin\u003c/b\u003e less than 0.01 seconds (10 milliseconds).\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) must address each of the elements of your problem specification:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function.\u003c/li\u003e\u003cli\u003eEnsure that the returned \u003cb\u003edata type\u003c/b\u003e is suitable.\u003c/li\u003e\u003cli\u003eYou \u003cb\u003ecannot\u003c/b\u003e use (or mention) the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ctt\u003ecscd\u003c/tt\u003e or \u003ctt\u003ecosd\u003c/tt\u003e in your Test Suite;  any other functions are allowed.  [ \u003ci\u003eMOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/i\u003e ]\u003c/li\u003e\u003cli\u003eYou must check that I \u003cb\u003ehaven't used\u003c/b\u003e \"regexp\" or \"regexpi\" or \"ans\".  You could try using the \u003ca href = \"https://au.mathworks.com/help/coursework/ug/assessfunctionabsence.html\"\u003e\u003ctt\u003eassessFunctionAbsence\u003c/tt\u003e\u003c/a\u003e function in the form \u003ctt\u003eassessFunctionAbsence(..., 'FileName','SINE.m')\u003c/tt\u003e, or else you could try 'manually' opening the file \u003ctt\u003eSINE.m\u003c/tt\u003e that corresponds to my submitted solution and then parsing it for occurrence of the prohibited function/variable.\u003c/li\u003e\u003cli\u003eYou must check that my code returns a result within \u003cb\u003eless than 0.01 seconds\u003c/b\u003e (for a single input of an arbitrary angle).  You could use \u003ca href = \"https://au.mathworks.com/help/matlab/ref/tic.html\"\u003e\u003ctt\u003etic\u003c/tt\u003e\u003c/a\u003e \u0026 \u003ca href = \"https://au.mathworks.com/help/matlab/ref/toc.html\"\u003e\u003ctt\u003etoc\u003c/tt\u003e\u003c/a\u003e or \u003ca href = \"https://au.mathworks.com/help/matlab/ref/timeit.html\"\u003e\u003ctt\u003etimeit\u003c/tt\u003e\u003c/a\u003e, or a variety of other MATLAB functions (but not \u003ctt\u003ecputime\u003c/tt\u003e in this case).  If your Test Suite claims that my submission runs slowly, then you must be confident that it is truly caused only by inefficiency in my submitted code, \u003cb\u003enot\u003c/b\u003e just general/erratic overheads in 'queuing' or suchlike on the Cody servers.\u003c/li\u003e\u003cli\u003eYour \u003ctt\u003eassert\u003c/tt\u003e (or other) function must throw \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e with the following \u003cb\u003e\u003ctt\u003eerror message\u003c/tt\u003e text\u003c/b\u003e contents.\u003c/li\u003e\u003c/ol\u003e\u003cul\u003e\u003cli\u003e'Incorrect value' if the output is too inaccurate.\u003c/li\u003e\u003cli\u003e'Incorrect data type' if the output is not appropriate.\u003c/li\u003e\u003cli\u003e'Too slow' if my submitted code is too slow.\u003c/li\u003e\u003cli\u003e'Banned word' if my submitted code contains the \u003ctt\u003eregexp\u003c/tt\u003e or \u003ctt\u003eregexpi\u003c/tt\u003e functions or the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/ans.html\"\u003e\u003ctt\u003eans\u003c/tt\u003e\u003c/a\u003e variable.  For \u003ci\u003ethis\u003c/i\u003e infringement, \u003ci\u003eadditional\u003c/i\u003e text can \u003ci\u003ealso\u003c/i\u003e (optionally!) be present in the message — for example, 'You cannot do that!  Banned word (regexp/regexpi)' would also be acceptable.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44631\"\u003eProblem 44631\u003c/a\u003e (part \u003cb\u003e0\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44617\"\u003eProblem 44617\u003c/a\u003e (part \u003cb\u003e1\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44616\"\u003eProblem 44616\u003c/a\u003e (part \u003cb\u003e2\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    %% Test 1 — test outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n    \r\n    %% Test 2 — test for use/presence of  \"regexp\" or \"regexpi\" or \"ans\" in the submission\r\n    % MOTIVATION:  The functions regexp and regexpi are sometimes pertinent to efficient solution of a problem, \r\n    %              but at other times are used to artificially decrease the size of a Cody submission.\r\n    %              If I'm using regexp or regexpi for *this* problem of yours (where neither is relevant), \r\n    %              then it's probably because I'm trying to 'cheat' to get a smaller Cody score.\r\n    %              Use of the ans variable is also generally employed purely to decrease\r\n    %              Cody size, at the expense of clarity in the code.  \r\n    assessFunctionAbsence( '' , 'FileName','SINE.m' )\r\n\r\n    \r\n    %% Test 3 — check the speed of execution of the submission \r\n    % MOTIVATION:  Some code that is rated as \"small\" on Cody is actually quite computationally inefficient, \r\n    %              but it is possible to 'manually' enforce a requirement for Cody submissions to be at least \r\n    %              moderately efficient.  See e.g. Cody Problems 44351, 44356 \u0026 44383.  \r\n    %              So this will balance the Cody focus on small code 'size' with \r\n    %              the desire to ensure code is also computationally efficient.\r\n    toc\r\n    timeit( SINE(45) )\r\n    duration = tic\r\n    assert( duration , '' )\r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}\r\n\r\n%{\r\nFOOTNOTE:  \r\nAlthough 10 milliseconds may not seem like a slow execution time, \r\ncomputing the sine of an angle is a very common task, and a general program \r\nmight need to compute it hundreds, thousands or even millions of times.  \r\nIn the latter case, if each computation of sine were to take more than 10 \r\nmilliseconds, then the hypothetical program would run for several hours.  \r\nBy way of comparison, for a 1×1000000 vector input MATLAB's built-in sin \r\nfunction is currently taking a total of about 10 to 25 milliseconds on Cody, \r\nwhile sind is taking about 20 to 50 milliseconds._  \r\n%}","test_suite":"%% Timing\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfprintf(fileID,'   pause(0.012);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Too slow') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Use of ans\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function ans = SINE(angle)\\n');\r\nfprintf(fileID,'   sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    e.message\r\n    assert( contains(e.message, 'Banned word') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Possible false alarm for use of ans\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   % This is a simple problem:  the answer only takes one line!\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Use of regexp/regexpi (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfprintf(fileID,'   dummy = regexp(''Test text'', ''t'');\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    e.message\r\n    assert( contains(e.message, 'Banned word') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Use of regexp/regexpi (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfprintf(fileID,'   dummy = regexpi(''Test text'', ''t'');\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    e.message\r\n    assert( contains(e.message, 'Banned word') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Ensure no \"sind\" or \"sin\" or \"cosd\" in _your_ Test Suite\r\n% NOTE:  You may notice that the user function has been named \"SINE\", \r\n%        in uppercase.  That is an extra precaution to avoid accidentally \r\n%        triggering an error due to a banned 'word' (sequence of characters).  \r\n%        Careful choice of code to check for banned _functions_ is better!  \r\nassessFunctionAbsence('sind', 'FileName','testSuite.m')\r\nassessFunctionAbsence('sin',  'FileName','testSuite.m')\r\nassessFunctionAbsence('cscd', 'FileName','testSuite.m')\r\nassessFunctionAbsence('cosd', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int8(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int16(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int32(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int64(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(double(int32(angle)));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"ratio\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"?\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {1:1E4};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Wrong data type\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {sind(angle)};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":"2018-04-18T14:04:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-02-13T12:05:07.000Z","updated_at":"2018-05-11T13:20:58.000Z","published_at":"2018-02-20T13:11:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to implement a robust Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not, and to be fairly assured that I am not trying to 'game' the system.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewithout\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e using\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexpi\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eans\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewithin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e less than 0.01 seconds (10 milliseconds).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) must address each of the elements of your problem specification:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEnsure that the returned\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edata type\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is suitable.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use (or mention) the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecscd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecosd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in your Test Suite; any other functions are allowed. [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eMOTIVATION: You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou must check that I\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ehaven't used\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \\\"regexp\\\" or \\\"regexpi\\\" or \\\"ans\\\". You could try using the\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://au.mathworks.com/help/coursework/ug/assessfunctionabsence.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassessFunctionAbsence\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function in the form\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassessFunctionAbsence(..., 'FileName','SINE.m')\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, or else you could try 'manually' opening the file\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSINE.m\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that corresponds to my submitted solution and then parsing it for occurrence of the prohibited function/variable.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou must check that my code returns a result within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eless than 0.01 seconds\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (for a single input of an arbitrary angle). You could use\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://au.mathworks.com/help/matlab/ref/tic.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etic\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026amp;\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://au.mathworks.com/help/matlab/ref/toc.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etoc\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e or\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://au.mathworks.com/help/matlab/ref/timeit.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etimeit\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, or a variety of other MATLAB functions (but not\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecputime\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in this case). If your Test Suite claims that my submission runs slowly, then you must be confident that it is truly caused only by inefficiency in my submitted code,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e just general/erratic overheads in 'queuing' or suchlike on the Cody servers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (or other) function must throw\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e with the following\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eerror message\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e text\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e contents.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect value' if the output is too inaccurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect data type' if the output is not appropriate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Too slow' if my submitted code is too slow.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Banned word' if my submitted code contains the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexpi\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e functions or the\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://au.mathworks.com/help/matlab/ref/ans.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eans\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e variable. For\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethis\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e infringement,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eadditional\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e text can\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ealso\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (optionally!) be present in the message — for example, 'You cannot do that! Banned word (regexp/regexpi)' would also be acceptable.\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\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\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 also:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44631\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44631\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44617\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44617\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44616\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44616\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44616,"title":"Make your own Test Suite (part 2)","description":"In this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to develop a Test Suite* to check whether _my_ submitted solutions meet _your_ requirements or not.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain.\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour Test Suite (contained within _your_ function |testSuite|) must address each of the elements of your problem specification:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function.  \r\n# Ensure that the returned *data type* is suitable.  \r\n# You *cannot* use (or mention) the functions |sind|, |sin|, |cscd| or |cosd| in your Test Suite;  any other functions are allowed.  [ _MOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!_ ]\r\n# Your |assert| (or other) function must throw \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e with the following *|error message| text* contents.\r\n\r\n* 'Incorrect value' if the output is too inaccurate.\r\n* 'Incorrect data type' if the output is not appropriate.\r\n\r\nWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  \r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44631 Problem 44631\u003e (part *0*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44617 Problem 44617\u003e (part *1*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44521 Problem 44521\u003e (part *3*)","description_html":"\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to develop a Test Suite\u003c/b\u003e to check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) must address each of the elements of your problem specification:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function.\u003c/li\u003e\u003cli\u003eEnsure that the returned \u003cb\u003edata type\u003c/b\u003e is suitable.\u003c/li\u003e\u003cli\u003eYou \u003cb\u003ecannot\u003c/b\u003e use (or mention) the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ctt\u003ecscd\u003c/tt\u003e or \u003ctt\u003ecosd\u003c/tt\u003e in your Test Suite;  any other functions are allowed.  [ \u003ci\u003eMOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/i\u003e ]\u003c/li\u003e\u003cli\u003eYour \u003ctt\u003eassert\u003c/tt\u003e (or other) function must throw \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e with the following \u003cb\u003e\u003ctt\u003eerror message\u003c/tt\u003e text\u003c/b\u003e contents.\u003c/li\u003e\u003c/ol\u003e\u003cul\u003e\u003cli\u003e'Incorrect value' if the output is too inaccurate.\u003c/li\u003e\u003cli\u003e'Incorrect data type' if the output is not appropriate.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44631\"\u003eProblem 44631\u003c/a\u003e (part \u003cb\u003e0\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44617\"\u003eProblem 44617\u003c/a\u003e (part \u003cb\u003e1\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44521\"\u003eProblem 44521\u003c/a\u003e (part \u003cb\u003e3\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    % Test A — test outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    \r\n    %% Part 1\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n    %% Part 2\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n    %% Part 3\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n\r\n    %% Test B — test outputs of submitted SINE function to ensure the data type is correct.\r\n    \r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}\r\n","test_suite":"%% Ensure no \"sind\" or \"sin\" or \"cosd\" in _your_ Test Suite\r\n% NOTE:  You may notice that the user function has been named \"SINE\", \r\n%        in uppercase.  That is an extra precaution to avoid accidentally \r\n%        triggering an error due to a banned 'word' (sequence of characters).  \r\n%        Careful choice of code to check for banned _functions_ is better!  \r\nassessFunctionAbsence('sind', 'FileName','testSuite.m')\r\nassessFunctionAbsence('sin',  'FileName','testSuite.m')\r\nassessFunctionAbsence('cscd', 'FileName','testSuite.m')\r\nassessFunctionAbsence('cosd', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int8(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int16(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int32(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int64(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(double(int32(angle)));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"ratio\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"?\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {1:1E4};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Wrong data type\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {sind(angle)};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-18T13:09:12.000Z","updated_at":"2018-05-11T13:19:31.000Z","published_at":"2018-04-18T13: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\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to develop a Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) must address each of the elements of your problem specification:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEnsure that the returned\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edata type\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is suitable.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use (or mention) the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecscd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecosd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in your Test Suite; any other functions are allowed. [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eMOTIVATION: You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (or other) function must throw\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e with the following\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eerror message\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e text\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e contents.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect value' if the output is too inaccurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect data type' if the output is not appropriate.\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\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\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 also:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44631\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44631\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44617\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44617\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44521\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44521\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44617,"title":"Make your own Test Suite (part 1)","description":"In this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to prepare a simple Test Suite* to check whether _my_ submitted solutions meet _your_ requirements or not.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain.\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour Test Suite (contained within _your_ function |testSuite|) must address each of the elements of your problem specification:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function to generate \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e if the values are not sufficiently accurate.  \r\n# You *cannot* use (or mention) the functions |sind|, |sin|, |cscd| or |cosd| in your Test Suite;  any other functions are allowed.  [ _MOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!_ ]\r\n\r\nWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  Therefore the above specification is merely a _starting point_.  You will develop more robust Test Suites in:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44616 Problem 44616\u003e (part *2*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44521 Problem 44521\u003e (part *3*)\r\n\r\nAlternatively, if even this Problem seems daunting, you may want to start with \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44631 Problem 44631\u003e (part *0*).","description_html":"\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to prepare a simple Test Suite\u003c/b\u003e to check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) must address each of the elements of your problem specification:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function to generate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e if the values are not sufficiently accurate.\u003c/li\u003e\u003cli\u003eYou \u003cb\u003ecannot\u003c/b\u003e use (or mention) the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ctt\u003ecscd\u003c/tt\u003e or \u003ctt\u003ecosd\u003c/tt\u003e in your Test Suite;  any other functions are allowed.  [ \u003ci\u003eMOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/i\u003e ]\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  Therefore the above specification is merely a \u003ci\u003estarting point\u003c/i\u003e.  You will develop more robust Test Suites in:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44616\"\u003eProblem 44616\u003c/a\u003e (part \u003cb\u003e2\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44521\"\u003eProblem 44521\u003c/a\u003e (part \u003cb\u003e3\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eAlternatively, if even this Problem seems daunting, you may want to start with \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44631\"\u003eProblem 44631\u003c/a\u003e (part \u003cb\u003e0\u003c/b\u003e).\u003c/p\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    % Check outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    \r\n    %% Test 1\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 2\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 3\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 4\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n\r\n    %% Test 5\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 6\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 7\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}","test_suite":"%% Ensure no \"sind\" or \"sin\" or \"cosd\" in _your_ Test Suite\r\n% NOTE:  You may notice that the user function has been named \"SINE\", \r\n%        in uppercase.  That is an extra precaution to avoid accidentally \r\n%        triggering an error due to a banned 'word' (sequence of characters).  \r\n%        Careful choice of code to check for banned _functions_ is better!  \r\nassessFunctionAbsence('sind', 'FileName','testSuite.m')\r\nassessFunctionAbsence('sin',  'FileName','testSuite.m')\r\nassessFunctionAbsence('cscd', 'FileName','testSuite.m')\r\nassessFunctionAbsence('cosd', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int8(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int16(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int32(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int64(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(double(int32(angle)));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-18T13:35:30.000Z","updated_at":"2018-05-11T13:20:07.000Z","published_at":"2018-04-18T13:49:32.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to prepare a simple Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) must address each of the elements of your problem specification:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function to generate\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e if the values are not sufficiently accurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use (or mention) the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecscd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecosd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in your Test Suite; any other functions are allowed. [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eMOTIVATION: You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ! Therefore the above specification is merely a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estarting point\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. You will develop more robust Test Suites in:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44616\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44616\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44521\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44521\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAlternatively, if even this Problem seems daunting, you may want to start with\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/44631\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44631\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44631,"title":"Make your own Test Suite (part 0)","description":"_Have no knowledge of \u003chttps://au.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html \"floating-point numbers\"\u003e?  Read the documentation, and/or try \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44690 Problem 44690\u003e first._\r\n\r\n——————————————————————————————————————————\r\n\r\nIn this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to draft a naïve Test Suite* as the first step in developing a more robust Test Suite that would check whether _my_ submitted solutions meet _your_ requirements or not.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain.\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour final Test Suite (contained within _your_ function |testSuite|) will have to address several aspects arising in your problem specification.  However, for this 'first draft' you are creating a naïve Test Suite with only one requirement:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function to generate \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e if the values are not sufficiently accurate.  \r\n\r\nYou *can* use the functions |sind|, |sin|, _etc._ in this draft Test Suite, if you want — even though this would be bad practice in your final Test Suite! \r\n\r\nThus, the above specification is merely a _starting point_.  You will develop more robust Test Suites in:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44617 Problem 44617\u003e (part *1*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44616 Problem 44616\u003e (part *2*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44521 Problem 44521\u003e (part *3*)","description_html":"\u003cp\u003e\u003ci\u003eHave no knowledge of \u003ca href = \"https://au.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html\"\u003e\"floating-point numbers\"\u003c/a\u003e?  Read the documentation, and/or try \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44690\"\u003eProblem 44690\u003c/a\u003e first.\u003c/i\u003e\u003c/p\u003e\u003cp\u003e——————————————————————————————————————————\u003c/p\u003e\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to draft a naïve Test Suite\u003c/b\u003e as the first step in developing a more robust Test Suite that would check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour final Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) will have to address several aspects arising in your problem specification.  However, for this 'first draft' you are creating a naïve Test Suite with only one requirement:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function to generate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e if the values are not sufficiently accurate.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eYou \u003cb\u003ecan\u003c/b\u003e use the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ci\u003eetc.\u003c/i\u003e in this draft Test Suite, if you want — even though this would be bad practice in your final Test Suite!\u003c/p\u003e\u003cp\u003eThus, the above specification is merely a \u003ci\u003estarting point\u003c/i\u003e.  You will develop more robust Test Suites in:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44617\"\u003eProblem 44617\u003c/a\u003e (part \u003cb\u003e1\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44616\"\u003eProblem 44616\u003c/a\u003e (part \u003cb\u003e2\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44521\"\u003eProblem 44521\u003c/a\u003e (part \u003cb\u003e3\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    % Check outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    \r\n    %% Test 1\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 2\r\n    assert( isequal( SINE(45), sine(45) )  )\r\n    \r\n    %% Test 3\r\n    assert( isequal( SINE(45), sin(45) )  )\r\n    \r\n    %% Test 4\r\n    assert( isequal( SINE(45), sind(45) )  )\r\n\r\n    %% Test 5\r\n    assert( isequal( SINE(45), sine(1/sqrt(2)) )  )\r\n    \r\n    %% Test 6\r\n    assert( isequal( SINE(45), sin(1/sqrt(2)) )  )\r\n    \r\n    %% Test 7\r\n    assert( isequal( SINE(45), sind(1/sqrt(2)) )  )\r\n    \r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}","test_suite":"%% Placeholder\r\n%assessFunctionAbsence('sind', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":6,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-05T12:36:47.000Z","updated_at":"2018-06-17T02:29:04.000Z","published_at":"2018-05-05T13:35:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHave no knowledge of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"floating-point numbers\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e? Read the documentation, and/or try\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44690\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem 44690\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e first.\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——————————————————————————————————————————\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\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to draft a naïve Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as the first step in developing a more robust Test Suite that would check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour final Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) will have to address several aspects arising in your problem specification. However, for this 'first draft' you are creating a naïve Test Suite with only one requirement:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function to generate\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e if the values are not sufficiently accurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecan\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eetc.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in this draft Test Suite, if you want — even though this would be bad practice in your final Test Suite!\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\u003eThus, the above specification is merely a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estarting point\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. You will develop more robust Test Suites in:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44617\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44617\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44616\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44616\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44521\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44521\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44655,"title":"Computational power of Cody servers","description":"It has been \u003chttps://en.wikipedia.org/wiki/Moore%27s_law#History predicted\u003e that the performance of integrated circuits would _double_ every 18 months.  That suggests the time to perform a given computation should _halve_ roughly every 18 months.  \r\n\r\nWhat about on Cody?  Observational data is available from the final test case of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/963-we-love-vectorized-solutions-problem-1-remove-the-row-average Problem 963\u003e to help us quantify the improvement in performance!  And thereby even make predictions for future computations.\r\n\r\n Solution    Date\t   Runtime [s]\r\n ...\r\n 144393\t     04-Oct-12\t   4.230\r\n ...\r\n 654812\t     17-Apr-15\t   3.099\r\n ...\r\n 1272817     20-Sep-17\t   2.0402\r\n ...\r\n\r\nThe complete data set will be provided to you as input.  You should assume the general trend can be described by the following law:\r\n\r\n runtime = r0 - δ [1 - exp(-t/k)]\r\n runtime = r∞ + δ exp(-t/k)\r\n\r\nwhere |r0| is the runtime at the start of the period in seconds, |r∞| is the predicted runtime (in seconds) that will be approached far in the future, |δ = r0 - r∞|, and |t| is the time in nominal years since the start of the period, and |k| is a kinetic parameter (in nominal years).  \r\n\r\nThe start of the period is defined by the earliest date in the series.  Compute the number of days exactly, and assume that a nominal year comprises 365.24 days.\r\n\r\nYour task is to \u003chttps://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html fit the curve\u003e and thereby predict the runtime for various future dates.  Your output should be rounded to four decimal places.  \r\n\r\nMETHOD:  You _must_ use \u003chttps://au.mathworks.com/help/matlab/ref/fminsearch.html |fminsearch|\u003e to perform the non-linear regression, and you _must_ set the options using \u003chttps://au.mathworks.com/help/matlab/ref/optimset.html |optimset|\u003e to ensure sufficient accuracy.  The 'best' fit is defined — _for this problem, as in the common convention_ — as that which minimises the sum of the squares of the residuals.  \r\n\r\nEXAMPLE:\r\n\r\n % Input\r\n futureDate = '21-Nov-2023';\r\n data.solutionNumber = [1036949, ..., 1272817];\r\n data.date = ['29-Oct-2016'; ...; '20-Sep-2017'];\r\n data.runtime = [1.2630, ..., 2.0402];\r\n % Output\r\n predictedRuntime = 0.3619;  % seconds\r\n\r\n","description_html":"\u003cp\u003eIt has been \u003ca href = \"https://en.wikipedia.org/wiki/Moore%27s_law#History\"\u003epredicted\u003c/a\u003e that the performance of integrated circuits would \u003ci\u003edouble\u003c/i\u003e every 18 months.  That suggests the time to perform a given computation should \u003ci\u003ehalve\u003c/i\u003e roughly every 18 months.\u003c/p\u003e\u003cp\u003eWhat about on Cody?  Observational data is available from the final test case of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/963-we-love-vectorized-solutions-problem-1-remove-the-row-average\"\u003eProblem 963\u003c/a\u003e to help us quantify the improvement in performance!  And thereby even make predictions for future computations.\u003c/p\u003e\u003cpre\u003e Solution    Date\t   Runtime [s]\r\n ...\r\n 144393\t     04-Oct-12\t   4.230\r\n ...\r\n 654812\t     17-Apr-15\t   3.099\r\n ...\r\n 1272817     20-Sep-17\t   2.0402\r\n ...\u003c/pre\u003e\u003cp\u003eThe complete data set will be provided to you as input.  You should assume the general trend can be described by the following law:\u003c/p\u003e\u003cpre\u003e runtime = r0 - δ [1 - exp(-t/k)]\r\n runtime = r∞ + δ exp(-t/k)\u003c/pre\u003e\u003cp\u003ewhere \u003ctt\u003er0\u003c/tt\u003e is the runtime at the start of the period in seconds, \u003ctt\u003er∞\u003c/tt\u003e is the predicted runtime (in seconds) that will be approached far in the future, \u003ctt\u003eδ = r0 - r∞\u003c/tt\u003e, and \u003ctt\u003et\u003c/tt\u003e is the time in nominal years since the start of the period, and \u003ctt\u003ek\u003c/tt\u003e is a kinetic parameter (in nominal years).\u003c/p\u003e\u003cp\u003eThe start of the period is defined by the earliest date in the series.  Compute the number of days exactly, and assume that a nominal year comprises 365.24 days.\u003c/p\u003e\u003cp\u003eYour task is to \u003ca href = \"https://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html\"\u003efit the curve\u003c/a\u003e and thereby predict the runtime for various future dates.  Your output should be rounded to four decimal places.\u003c/p\u003e\u003cp\u003eMETHOD:  You \u003ci\u003emust\u003c/i\u003e use \u003ca href = \"https://au.mathworks.com/help/matlab/ref/fminsearch.html\"\u003e\u003ctt\u003efminsearch\u003c/tt\u003e\u003c/a\u003e to perform the non-linear regression, and you \u003ci\u003emust\u003c/i\u003e set the options using \u003ca href = \"https://au.mathworks.com/help/matlab/ref/optimset.html\"\u003e\u003ctt\u003eoptimset\u003c/tt\u003e\u003c/a\u003e to ensure sufficient accuracy.  The 'best' fit is defined — \u003ci\u003efor this problem, as in the common convention\u003c/i\u003e — as that which minimises the sum of the squares of the residuals.\u003c/p\u003e\u003cp\u003eEXAMPLE:\u003c/p\u003e\u003cpre\u003e % Input\r\n futureDate = '21-Nov-2023';\r\n data.solutionNumber = [1036949, ..., 1272817];\r\n data.date = ['29-Oct-2016'; ...; '20-Sep-2017'];\r\n data.runtime = [1.2630, ..., 2.0402];\r\n % Output\r\n predictedRuntime = 0.3619;  % seconds\u003c/pre\u003e","function_template":"function predictedRuntime = predictor(futureDate, data)\r\n    % Preliminaries:\r\n    ...\r\n    \r\n    \r\n    % Use fminsearch to find the parameters that minimize the objective function.\r\n    myObjectiveFun = ...\r\n    myOptions = ...\r\n    ... = fminsearch\r\n\r\n    % Report your prediction of the runtime at the specified future date.\r\n    predictedRuntime = ...\r\nend\r\n\r\n% Function that accepts a trial set of parameters and the observed data, \r\n% and returns the sum of squared errors for the model . \r\n% https://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html\r\nfunction SSE = sseVal(...)\r\n    % runtime = r0 - δ [1 - exp(-t/k)]\r\n    % runtime = r∞ + δ exp(-t/k)\r\n    \r\n    ...\r\n    \r\n    SSE = ...\r\nend\r\n","test_suite":"data.solutionNumber = [1036949\t1048171\t1051202\t1078061\t1078699\t1081561\t886761\t1165117\t1202850\t1211446\t1241478\t1241530\t1329044\t1323931\t1382633\t1345204\t1281524\t1272814\t1272815\t1272823\t1272845\t1287012\t1287386\t1262442\t1262445\t1251993\t1252843\t1407137\t1412687\t1448359\t1448368\t1410187\t1465616\t1472214\t1472225\t1490596\t1490602\t1541085\t1541132\t860114\t143879\t144156\t144393\t202249\t210894\t539555\t182974\t276887\t1133109\t654812\t1272817];\r\ndata.date = ['29-Oct-2016';\t'08-Nov-2016';\t'12-Nov-2016';\t'09-Dec-2016';\t'10-Dec-2016';\t'14-Dec-2016';\t'06-May-2016';\t'18-Apr-2017';\t'02-Jun-2017';\t'13-Jun-2017';\t'28-Jul-2017';\t'28-Jul-2017';\t'06-Nov-2017';\t'01-Nov-2017';\t'16-Dec-2017';\t'15-Nov-2017';\t'05-Oct-2017';\t'20-Sep-2017';\t'20-Sep-2017';\t'20-Sep-2017';\t'20-Sep-2017';\t'15-Oct-2017';\t'15-Oct-2017';\t'05-Sep-2017';\t'05-Sep-2017';\t'16-Aug-2017';\t'17-Aug-2017';\t'06-Jan-2018';\t'10-Jan-2018';\t'24-Feb-2018';\t'24-Feb-2018';\t'08-Jan-2018';\t'18-Mar-2018';\t'27-Mar-2018';\t'27-Mar-2018';\t'13-Apr-2018';\t'13-Apr-2018';\t'26-May-2018';\t'26-May-2018';\t'31-Mar-2016';\t'02-Oct-2012';\t'03-Oct-2012';\t'04-Oct-2012';\t'08-Feb-2013';\t'01-Mar-2013';\t'03-Dec-2014';\t'29-Dec-2012';\t'09-Jul-2013';\t'03-Mar-2017';\t'17-Apr-2015';\t'20-Sep-2017'];\r\ndata.runtime = [1.2630\t0.624\t1.3326\t1.2939\t0.5995\t1.1307\t1.3505\t1.2613\t1.2737\t1.3081\t1.2774\t1.252\t1.2179\t1.4431\t1.2637\t1.1614\t1.2542\t1.9135\t1.2996\t1.2595\t1.2664\t1.1858\t1.1501\t1.2516\t1.2786\t1.9461\t1.2492\t1.3654\t1.3263\t1.1484\t1.1728\t1.6177\t1.0538\t1.0571\t1.0454\t1.3873\t1.0600\t1.1154\t1.0635\t1.4359\t4.498\t4.198\t4.230\t5.264\t4.022\t3.153\t4.740\t4.112\t2.3409\t3.099\t2.0402];\r\n\r\n%% Anti-hacking provision\r\n% ADDED 2019-06-29.  \r\n% Ensure only builtin functions will be called.  \r\n! rm -v fileread.m\r\n! rm -v assert.m\r\n\r\n%% Required methodology\r\nassessFunctionPresence({'fminsearch', 'optimset'}, 'FileName','predictor.m', 'Feedback','You must use the specified methodology')\r\n\r\n%% Anti-hardcoding test\r\n% Adapted from a comment at https://www.mathworks.com/matlabcentral/cody/problems/44343 .\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[2012,2019:2023,3000]),regexp(fileread('predictor.m'),'[\\d\\.\\+\\-\\*\\/\\(\\) \\[\\]\\,\\;]+','match'))), 'Please don''t hard-code your ''solution''.') \r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[2012,2019:2023,3000]),regexp(fileread('predictor.m'),'\\d+','match'))), 'Please do not hard-code your ''solution''.') \r\n\r\n%% January 2019\r\nfutureDate = '22-Jan-2019';\r\npredictedRuntime_correct = round(0.935043294718475, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '23-Jan-2019';\r\npredictedRuntime_correct = round(0.934448955935569, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '24-Jan-2019';\r\npredictedRuntime_correct = round(0.933855075296061, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% January 2020\r\nfutureDate = '09-Jan-2020';\r\npredictedRuntime_correct = round(0.751755426901932, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '13-Jan-2020';\r\npredictedRuntime_correct = round(0.749945312632780, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% January 2021\r\nfutureDate = '06-Jan-2021';\r\npredictedRuntime_correct = round(0.608254613313523, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '11-Jan-2021';\r\npredictedRuntime_correct = round(0.606545074994730, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% February 2022\r\nfutureDate = '06-Feb-2022';\r\npredictedRuntime_correct = round(0.491354117473879, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '10-Feb-2022';\r\npredictedRuntime_correct = round(0.490345992043568, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% November 2023\r\nfutureDate = '06-Nov-2023';\r\npredictedRuntime_correct = round(0.364155581026111, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '21-Nov-2023';\r\npredictedRuntime_correct = round(0.361853937995679, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '25-Nov-2023';\r\npredictedRuntime_correct = round(0.361244649648014, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '27-Nov-2023';\r\npredictedRuntime_correct = round(0.360940709522436, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% Let's all meet up in the year 3000\r\nfutureDate = '01-Jan-3000';\r\npredictedRuntime_correct = round(0.164021404839, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% Enforce antihacking\r\n% Assure no 'workarounds' that avoid appropriate use of optimset.\r\n% (Added 29 May 2018.)\r\nfutureDate = {'19-Dec-2019';\t'04-Oct-2020';\t'06-Nov-2020';\t'20-Nov-2020';\t'07-Dec-2020';\t'09-Dec-2020';\t'11-Dec-2020';\t'25-Feb-2021';\t'04-Mar-2021';\t'18-Apr-2021';\t'19-May-2021';\t'23-Jul-2021'};\r\npRuntime_c_unrounded = {0.761350673860113\t0.641651747331991\t0.629650497697623\t0.624650604424140\t0.618651428148657\t0.617950799242008\t0.617251250072375\t0.591452258418511\t0.589151203003048\t0.574651625923890\t0.564951737257372\t0.545350739105932};\r\nfor j = 1 : length(futureDate)\r\n    assert(isequal(predictor(futureDate{j}, data), round(pRuntime_c_unrounded{j}, 4)))\r\nend;\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":"2019-06-29T12:58:19.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-05-27T08:32:09.000Z","updated_at":"2019-06-29T12:58:19.000Z","published_at":"2018-05-27T12:35:16.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\u003eIt has been\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://en.wikipedia.org/wiki/Moore%27s_law#History\\\"\u003e\u003cw:r\u003e\u003cw:t\u003epredicted\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e that the performance of integrated circuits would\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e every 18 months. That suggests the time to perform a given computation should\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ehalve\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e roughly every 18 months.\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\u003eWhat about on Cody? Observational data is available from the final test case 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/963-we-love-vectorized-solutions-problem-1-remove-the-row-average\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 963\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to help us quantify the improvement in performance! And thereby even make predictions for future computations.\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[ Solution    Date     Runtime [s]\\n ...\\n 144393       04-Oct-12     4.230\\n ...\\n 654812       17-Apr-15     3.099\\n ...\\n 1272817     20-Sep-17     2.0402\\n ...]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe complete data set will be provided to you as input. You should assume the general trend can be described by the following law:\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[ runtime = r0 - δ [1 - exp(-t/k)]\\n runtime = r∞ + δ exp(-t/k)]]\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\u003ewhere\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003er0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the runtime at the start of the period in seconds,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003er∞\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the predicted runtime (in seconds) that will be approached far in the future,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eδ = r0 - r∞\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003et\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the time in nominal years since the start of the period, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is a kinetic parameter (in nominal years).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe start of the period is defined by the earliest date in the series. Compute the number of days exactly, and assume that a nominal year comprises 365.24 days.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003efit the curve\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and thereby predict the runtime for various future dates. Your output should be rounded to four decimal places.\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\u003eMETHOD: You\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emust\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use\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://au.mathworks.com/help/matlab/ref/fminsearch.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efminsearch\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to perform the non-linear regression, and you\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emust\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e set the options using\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://au.mathworks.com/help/matlab/ref/optimset.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eoptimset\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to ensure sufficient accuracy. The 'best' fit is defined —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efor this problem, as in the common convention\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — as that which minimises the sum of the squares of the residuals.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % Input\\n futureDate = '21-Nov-2023';\\n data.solutionNumber = [1036949, ..., 1272817];\\n data.date = ['29-Oct-2016'; ...; '20-Sep-2017'];\\n data.runtime = [1.2630, ..., 2.0402];\\n % Output\\n predictedRuntime = 0.3619;  % seconds]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":2530,"title":"Powers Of","description":"Fill the vector with powers of 2, so that vector(1) is 2^1, vector(2) is 2^2, etc. Stop with vector(10).  Complete the function using a *for* loop.","description_html":"\u003cp\u003eFill the vector with powers of 2, so that vector(1) is 2^1, vector(2) is 2^2, etc. Stop with vector(10).  Complete the function using a \u003cb\u003efor\u003c/b\u003e loop.\u003c/p\u003e","function_template":"function vector = PowersOf(vector)\r\n  for ?\r\n    ?\r\n  end\r\nend","test_suite":"%%\r\nvector1 = [0 0 0 0 0 0 0 0 0 0];\r\nvector1_correct = [2 4 8 16 32 64 128 256 512 1024];\r\ncode = textread('PowersOf.m', '%s');\r\nassert(isequal(PowersOf(vector1), vector1_correct) \u0026\u0026 ...\r\n       strcmp(code(5), 'for') \u0026\u0026 ...\r\n       strcmp(code(end-7), 'end') \u0026\u0026 ...\r\n       strcmp(code(end-6), 'end'));","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":24594,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":108,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-08-26T12:47:32.000Z","updated_at":"2026-03-22T17:55:53.000Z","published_at":"2014-08-26T13:56:12.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\u003eFill the vector with powers of 2, so that vector(1) is 2^1, vector(2) is 2^2, etc. Stop with vector(10). Complete the function using a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efor\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e loop.\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":44521,"title":"Make your own Test Suite (part 3)","description":"In this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to implement a robust Test Suite* to check whether _my_ submitted solutions meet _your_ requirements or not, and to be fairly assured that I am not trying to 'game' the system.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain,   \r\n* *without* using |regexp| or |regexpi| or |ans|, \r\n* *within* less than 0.01 seconds (10 milliseconds).\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour Test Suite (contained within _your_ function |testSuite|) must address each of the elements of your problem specification:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function.  \r\n# Ensure that the returned *data type* is suitable.  \r\n# You *cannot* use (or mention) the functions |sind|, |sin|, |cscd| or |cosd| in your Test Suite;  any other functions are allowed.  [ _MOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!_ ]\r\n# You must check that I *haven't used* \"regexp\" or \"regexpi\" or \"ans\".  You could try using the \u003chttps://au.mathworks.com/help/coursework/ug/assessfunctionabsence.html |assessFunctionAbsence|\u003e function in the form |assessFunctionAbsence(..., 'FileName','SINE.m')|, or else you could try 'manually' opening the file |SINE.m| that corresponds to my submitted solution and then parsing it for occurrence of the prohibited function/variable.  \r\n# You must check that my code returns a result within *less than 0.01 seconds* (for a single input of an arbitrary angle).  You could use \u003chttps://au.mathworks.com/help/matlab/ref/tic.html |tic|\u003e \u0026 \u003chttps://au.mathworks.com/help/matlab/ref/toc.html |toc|\u003e or \u003chttps://au.mathworks.com/help/matlab/ref/timeit.html |timeit|\u003e, or a variety of other MATLAB functions (but not |cputime| in this case).  If your Test Suite claims that my submission runs slowly, then you must be confident that it is truly caused only by inefficiency in my submitted code, *not* just general/erratic overheads in 'queuing' or suchlike on the Cody servers.  \r\n# Your |assert| (or other) function must throw \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e with the following *|error message| text* contents.\r\n\r\n* 'Incorrect value' if the output is too inaccurate.\r\n* 'Incorrect data type' if the output is not appropriate.\r\n* 'Too slow' if my submitted code is too slow.\r\n* 'Banned word' if my submitted code contains the |regexp| or |regexpi| functions or the \u003chttps://au.mathworks.com/help/matlab/ref/ans.html |ans|\u003e variable.  For _this_ infringement, _additional_ text can _also_ (optionally!) be present in the message — for example, 'You cannot do that!  Banned word (regexp/regexpi)' would also be acceptable.\r\n\r\nWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  \r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44631 Problem 44631\u003e (part *0*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44617 Problem 44617\u003e (part *1*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44616 Problem 44616\u003e (part *2*)","description_html":"\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to implement a robust Test Suite\u003c/b\u003e to check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not, and to be fairly assured that I am not trying to 'game' the system.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain,\u003c/li\u003e\u003cli\u003e\u003cb\u003ewithout\u003c/b\u003e using \u003ctt\u003eregexp\u003c/tt\u003e or \u003ctt\u003eregexpi\u003c/tt\u003e or \u003ctt\u003eans\u003c/tt\u003e,\u003c/li\u003e\u003cli\u003e\u003cb\u003ewithin\u003c/b\u003e less than 0.01 seconds (10 milliseconds).\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) must address each of the elements of your problem specification:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function.\u003c/li\u003e\u003cli\u003eEnsure that the returned \u003cb\u003edata type\u003c/b\u003e is suitable.\u003c/li\u003e\u003cli\u003eYou \u003cb\u003ecannot\u003c/b\u003e use (or mention) the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ctt\u003ecscd\u003c/tt\u003e or \u003ctt\u003ecosd\u003c/tt\u003e in your Test Suite;  any other functions are allowed.  [ \u003ci\u003eMOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/i\u003e ]\u003c/li\u003e\u003cli\u003eYou must check that I \u003cb\u003ehaven't used\u003c/b\u003e \"regexp\" or \"regexpi\" or \"ans\".  You could try using the \u003ca href = \"https://au.mathworks.com/help/coursework/ug/assessfunctionabsence.html\"\u003e\u003ctt\u003eassessFunctionAbsence\u003c/tt\u003e\u003c/a\u003e function in the form \u003ctt\u003eassessFunctionAbsence(..., 'FileName','SINE.m')\u003c/tt\u003e, or else you could try 'manually' opening the file \u003ctt\u003eSINE.m\u003c/tt\u003e that corresponds to my submitted solution and then parsing it for occurrence of the prohibited function/variable.\u003c/li\u003e\u003cli\u003eYou must check that my code returns a result within \u003cb\u003eless than 0.01 seconds\u003c/b\u003e (for a single input of an arbitrary angle).  You could use \u003ca href = \"https://au.mathworks.com/help/matlab/ref/tic.html\"\u003e\u003ctt\u003etic\u003c/tt\u003e\u003c/a\u003e \u0026 \u003ca href = \"https://au.mathworks.com/help/matlab/ref/toc.html\"\u003e\u003ctt\u003etoc\u003c/tt\u003e\u003c/a\u003e or \u003ca href = \"https://au.mathworks.com/help/matlab/ref/timeit.html\"\u003e\u003ctt\u003etimeit\u003c/tt\u003e\u003c/a\u003e, or a variety of other MATLAB functions (but not \u003ctt\u003ecputime\u003c/tt\u003e in this case).  If your Test Suite claims that my submission runs slowly, then you must be confident that it is truly caused only by inefficiency in my submitted code, \u003cb\u003enot\u003c/b\u003e just general/erratic overheads in 'queuing' or suchlike on the Cody servers.\u003c/li\u003e\u003cli\u003eYour \u003ctt\u003eassert\u003c/tt\u003e (or other) function must throw \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e with the following \u003cb\u003e\u003ctt\u003eerror message\u003c/tt\u003e text\u003c/b\u003e contents.\u003c/li\u003e\u003c/ol\u003e\u003cul\u003e\u003cli\u003e'Incorrect value' if the output is too inaccurate.\u003c/li\u003e\u003cli\u003e'Incorrect data type' if the output is not appropriate.\u003c/li\u003e\u003cli\u003e'Too slow' if my submitted code is too slow.\u003c/li\u003e\u003cli\u003e'Banned word' if my submitted code contains the \u003ctt\u003eregexp\u003c/tt\u003e or \u003ctt\u003eregexpi\u003c/tt\u003e functions or the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/ans.html\"\u003e\u003ctt\u003eans\u003c/tt\u003e\u003c/a\u003e variable.  For \u003ci\u003ethis\u003c/i\u003e infringement, \u003ci\u003eadditional\u003c/i\u003e text can \u003ci\u003ealso\u003c/i\u003e (optionally!) be present in the message — for example, 'You cannot do that!  Banned word (regexp/regexpi)' would also be acceptable.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44631\"\u003eProblem 44631\u003c/a\u003e (part \u003cb\u003e0\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44617\"\u003eProblem 44617\u003c/a\u003e (part \u003cb\u003e1\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44616\"\u003eProblem 44616\u003c/a\u003e (part \u003cb\u003e2\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    %% Test 1 — test outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n    \r\n    %% Test 2 — test for use/presence of  \"regexp\" or \"regexpi\" or \"ans\" in the submission\r\n    % MOTIVATION:  The functions regexp and regexpi are sometimes pertinent to efficient solution of a problem, \r\n    %              but at other times are used to artificially decrease the size of a Cody submission.\r\n    %              If I'm using regexp or regexpi for *this* problem of yours (where neither is relevant), \r\n    %              then it's probably because I'm trying to 'cheat' to get a smaller Cody score.\r\n    %              Use of the ans variable is also generally employed purely to decrease\r\n    %              Cody size, at the expense of clarity in the code.  \r\n    assessFunctionAbsence( '' , 'FileName','SINE.m' )\r\n\r\n    \r\n    %% Test 3 — check the speed of execution of the submission \r\n    % MOTIVATION:  Some code that is rated as \"small\" on Cody is actually quite computationally inefficient, \r\n    %              but it is possible to 'manually' enforce a requirement for Cody submissions to be at least \r\n    %              moderately efficient.  See e.g. Cody Problems 44351, 44356 \u0026 44383.  \r\n    %              So this will balance the Cody focus on small code 'size' with \r\n    %              the desire to ensure code is also computationally efficient.\r\n    toc\r\n    timeit( SINE(45) )\r\n    duration = tic\r\n    assert( duration , '' )\r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}\r\n\r\n%{\r\nFOOTNOTE:  \r\nAlthough 10 milliseconds may not seem like a slow execution time, \r\ncomputing the sine of an angle is a very common task, and a general program \r\nmight need to compute it hundreds, thousands or even millions of times.  \r\nIn the latter case, if each computation of sine were to take more than 10 \r\nmilliseconds, then the hypothetical program would run for several hours.  \r\nBy way of comparison, for a 1×1000000 vector input MATLAB's built-in sin \r\nfunction is currently taking a total of about 10 to 25 milliseconds on Cody, \r\nwhile sind is taking about 20 to 50 milliseconds._  \r\n%}","test_suite":"%% Timing\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfprintf(fileID,'   pause(0.012);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Too slow') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Use of ans\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function ans = SINE(angle)\\n');\r\nfprintf(fileID,'   sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    e.message\r\n    assert( contains(e.message, 'Banned word') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Possible false alarm for use of ans\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   % This is a simple problem:  the answer only takes one line!\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Use of regexp/regexpi (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfprintf(fileID,'   dummy = regexp(''Test text'', ''t'');\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    e.message\r\n    assert( contains(e.message, 'Banned word') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Use of regexp/regexpi (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfprintf(fileID,'   dummy = regexpi(''Test text'', ''t'');\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    e.message\r\n    assert( contains(e.message, 'Banned word') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Ensure no \"sind\" or \"sin\" or \"cosd\" in _your_ Test Suite\r\n% NOTE:  You may notice that the user function has been named \"SINE\", \r\n%        in uppercase.  That is an extra precaution to avoid accidentally \r\n%        triggering an error due to a banned 'word' (sequence of characters).  \r\n%        Careful choice of code to check for banned _functions_ is better!  \r\nassessFunctionAbsence('sind', 'FileName','testSuite.m')\r\nassessFunctionAbsence('sin',  'FileName','testSuite.m')\r\nassessFunctionAbsence('cscd', 'FileName','testSuite.m')\r\nassessFunctionAbsence('cosd', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int8(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int16(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int32(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int64(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(double(int32(angle)));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"ratio\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"?\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {1:1E4};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Wrong data type\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {sind(angle)};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":"2018-04-18T14:04:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-02-13T12:05:07.000Z","updated_at":"2018-05-11T13:20:58.000Z","published_at":"2018-02-20T13:11:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to implement a robust Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not, and to be fairly assured that I am not trying to 'game' the system.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewithout\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e using\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexpi\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eans\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewithin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e less than 0.01 seconds (10 milliseconds).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) must address each of the elements of your problem specification:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEnsure that the returned\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edata type\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is suitable.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use (or mention) the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecscd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecosd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in your Test Suite; any other functions are allowed. [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eMOTIVATION: You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou must check that I\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ehaven't used\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \\\"regexp\\\" or \\\"regexpi\\\" or \\\"ans\\\". You could try using the\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://au.mathworks.com/help/coursework/ug/assessfunctionabsence.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassessFunctionAbsence\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function in the form\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassessFunctionAbsence(..., 'FileName','SINE.m')\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, or else you could try 'manually' opening the file\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eSINE.m\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that corresponds to my submitted solution and then parsing it for occurrence of the prohibited function/variable.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou must check that my code returns a result within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eless than 0.01 seconds\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (for a single input of an arbitrary angle). You could use\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://au.mathworks.com/help/matlab/ref/tic.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etic\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026amp;\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://au.mathworks.com/help/matlab/ref/toc.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etoc\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e or\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://au.mathworks.com/help/matlab/ref/timeit.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etimeit\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, or a variety of other MATLAB functions (but not\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecputime\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in this case). If your Test Suite claims that my submission runs slowly, then you must be confident that it is truly caused only by inefficiency in my submitted code,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e just general/erratic overheads in 'queuing' or suchlike on the Cody servers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (or other) function must throw\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e with the following\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eerror message\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e text\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e contents.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect value' if the output is too inaccurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect data type' if the output is not appropriate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Too slow' if my submitted code is too slow.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Banned word' if my submitted code contains the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eregexpi\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e functions or the\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://au.mathworks.com/help/matlab/ref/ans.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eans\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e variable. For\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ethis\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e infringement,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eadditional\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e text can\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ealso\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (optionally!) be present in the message — for example, 'You cannot do that! Banned word (regexp/regexpi)' would also be acceptable.\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\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\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 also:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44631\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44631\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44617\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44617\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44616\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44616\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44616,"title":"Make your own Test Suite (part 2)","description":"In this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to develop a Test Suite* to check whether _my_ submitted solutions meet _your_ requirements or not.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain.\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour Test Suite (contained within _your_ function |testSuite|) must address each of the elements of your problem specification:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function.  \r\n# Ensure that the returned *data type* is suitable.  \r\n# You *cannot* use (or mention) the functions |sind|, |sin|, |cscd| or |cosd| in your Test Suite;  any other functions are allowed.  [ _MOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!_ ]\r\n# Your |assert| (or other) function must throw \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e with the following *|error message| text* contents.\r\n\r\n* 'Incorrect value' if the output is too inaccurate.\r\n* 'Incorrect data type' if the output is not appropriate.\r\n\r\nWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  \r\n\r\nSee also:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44631 Problem 44631\u003e (part *0*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44617 Problem 44617\u003e (part *1*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44521 Problem 44521\u003e (part *3*)","description_html":"\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to develop a Test Suite\u003c/b\u003e to check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) must address each of the elements of your problem specification:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function.\u003c/li\u003e\u003cli\u003eEnsure that the returned \u003cb\u003edata type\u003c/b\u003e is suitable.\u003c/li\u003e\u003cli\u003eYou \u003cb\u003ecannot\u003c/b\u003e use (or mention) the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ctt\u003ecscd\u003c/tt\u003e or \u003ctt\u003ecosd\u003c/tt\u003e in your Test Suite;  any other functions are allowed.  [ \u003ci\u003eMOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/i\u003e ]\u003c/li\u003e\u003cli\u003eYour \u003ctt\u003eassert\u003c/tt\u003e (or other) function must throw \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e with the following \u003cb\u003e\u003ctt\u003eerror message\u003c/tt\u003e text\u003c/b\u003e contents.\u003c/li\u003e\u003c/ol\u003e\u003cul\u003e\u003cli\u003e'Incorrect value' if the output is too inaccurate.\u003c/li\u003e\u003cli\u003e'Incorrect data type' if the output is not appropriate.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\u003c/p\u003e\u003cp\u003eSee also:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44631\"\u003eProblem 44631\u003c/a\u003e (part \u003cb\u003e0\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44617\"\u003eProblem 44617\u003c/a\u003e (part \u003cb\u003e1\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44521\"\u003eProblem 44521\u003c/a\u003e (part \u003cb\u003e3\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    % Test A — test outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    \r\n    %% Part 1\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n    %% Part 2\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n    %% Part 3\r\n    assert( isequal( SINE(45), 1/sqrt(2) ) , '' )\r\n    \r\n\r\n    %% Test B — test outputs of submitted SINE function to ensure the data type is correct.\r\n    \r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}\r\n","test_suite":"%% Ensure no \"sind\" or \"sin\" or \"cosd\" in _your_ Test Suite\r\n% NOTE:  You may notice that the user function has been named \"SINE\", \r\n%        in uppercase.  That is an extra precaution to avoid accidentally \r\n%        triggering an error due to a banned 'word' (sequence of characters).  \r\n%        Careful choice of code to check for banned _functions_ is better!  \r\nassessFunctionAbsence('sind', 'FileName','testSuite.m')\r\nassessFunctionAbsence('sin',  'FileName','testSuite.m')\r\nassessFunctionAbsence('cscd', 'FileName','testSuite.m')\r\nassessFunctionAbsence('cosd', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int8(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int16(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int32(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int64(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') | ...\r\n            isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(double(int32(angle)));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect value') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"ratio\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = \"?\";\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Total nonsense (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {1:1E4};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Wrong data type\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = {sind(angle)};\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\n    assert( isequal(e.message, 'Incorrect data type') , 'Wrong message' )\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-18T13:09:12.000Z","updated_at":"2018-05-11T13:19:31.000Z","published_at":"2018-04-18T13: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\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to develop a Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) must address each of the elements of your problem specification:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEnsure that the returned\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edata type\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is suitable.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use (or mention) the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecscd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecosd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in your Test Suite; any other functions are allowed. [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eMOTIVATION: You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (or other) function must throw\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e with the following\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eerror message\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e text\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e contents.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect value' if the output is too inaccurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'Incorrect data type' if the output is not appropriate.\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\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!\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 also:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44631\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44631\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44617\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44617\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44521\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44521\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44617,"title":"Make your own Test Suite (part 1)","description":"In this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to prepare a simple Test Suite* to check whether _my_ submitted solutions meet _your_ requirements or not.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain.\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour Test Suite (contained within _your_ function |testSuite|) must address each of the elements of your problem specification:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function to generate \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e if the values are not sufficiently accurate.  \r\n# You *cannot* use (or mention) the functions |sind|, |sin|, |cscd| or |cosd| in your Test Suite;  any other functions are allowed.  [ _MOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!_ ]\r\n\r\nWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  Therefore the above specification is merely a _starting point_.  You will develop more robust Test Suites in:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44616 Problem 44616\u003e (part *2*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44521 Problem 44521\u003e (part *3*)\r\n\r\nAlternatively, if even this Problem seems daunting, you may want to start with \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44631 Problem 44631\u003e (part *0*).","description_html":"\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to prepare a simple Test Suite\u003c/b\u003e to check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) must address each of the elements of your problem specification:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function to generate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e if the values are not sufficiently accurate.\u003c/li\u003e\u003cli\u003eYou \u003cb\u003ecannot\u003c/b\u003e use (or mention) the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ctt\u003ecscd\u003c/tt\u003e or \u003ctt\u003ecosd\u003c/tt\u003e in your Test Suite;  any other functions are allowed.  [ \u003ci\u003eMOTIVATION:  You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/i\u003e ]\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ!  Therefore the above specification is merely a \u003ci\u003estarting point\u003c/i\u003e.  You will develop more robust Test Suites in:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44616\"\u003eProblem 44616\u003c/a\u003e (part \u003cb\u003e2\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44521\"\u003eProblem 44521\u003c/a\u003e (part \u003cb\u003e3\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eAlternatively, if even this Problem seems daunting, you may want to start with \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44631\"\u003eProblem 44631\u003c/a\u003e (part \u003cb\u003e0\u003c/b\u003e).\u003c/p\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    % Check outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    \r\n    %% Test 1\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 2\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 3\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 4\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n\r\n    %% Test 5\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 6\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 7\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}","test_suite":"%% Ensure no \"sind\" or \"sin\" or \"cosd\" in _your_ Test Suite\r\n% NOTE:  You may notice that the user function has been named \"SINE\", \r\n%        in uppercase.  That is an extra precaution to avoid accidentally \r\n%        triggering an error due to a banned 'word' (sequence of characters).  \r\n%        Careful choice of code to check for banned _functions_ is better!  \r\nassessFunctionAbsence('sind', 'FileName','testSuite.m')\r\nassessFunctionAbsence('sin',  'FileName','testSuite.m')\r\nassessFunctionAbsence('cscd', 'FileName','testSuite.m')\r\nassessFunctionAbsence('cosd', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int8(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int16(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nif rand() \u003c 0.5,\r\n    fprintf(fileID,'   s = int32(sind(angle));\\n');\r\nelse\r\n    fprintf(fileID,'   s = int64(sind(angle));\\n');\r\nend;\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Altered data type (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(double(int32(angle)));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-18T13:35:30.000Z","updated_at":"2018-05-11T13:20:07.000Z","published_at":"2018-04-18T13:49:32.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to prepare a simple Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) must address each of the elements of your problem specification:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function to generate\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e if the values are not sufficiently accurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecannot\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use (or mention) the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecscd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecosd\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in your Test Suite; any other functions are allowed. [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eMOTIVATION: You shouldn't be exposing an efficient way of solving the problem within your Test Suite, otherwise I can just copy and paste your solution and submit it as my own!\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhen creating a Test Suite for a Cody problem it is a good habit to try to anticipate the tactics that diverse Players might employ! Therefore the above specification is merely a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estarting point\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. You will develop more robust Test Suites in:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44616\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44616\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44521\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44521\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAlternatively, if even this Problem seems daunting, you may want to start with\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/44631\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44631\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44631,"title":"Make your own Test Suite (part 0)","description":"_Have no knowledge of \u003chttps://au.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html \"floating-point numbers\"\u003e?  Read the documentation, and/or try \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44690 Problem 44690\u003e first._\r\n\r\n——————————————————————————————————————————\r\n\r\nIn this task you need to imagine that you — _yes, YOU_ — have developed a problem on Cody for _me_ to solve, and now *you need to draft a naïve Test Suite* as the first step in developing a more robust Test Suite that would check whether _my_ submitted solutions meet _your_ requirements or not.  \r\n\r\nSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!  \r\n\r\nThe problem you've set me is to:\r\n\r\n* output the *sine* of an angle, when the angle is specified in degrees as a (scalar) \u003chttps://au.mathworks.com/help/matlab/ref/double.html |double|\u003e, with no restriction in the domain.\r\n\r\nYou provide me with the following example for the function defined as |s = SINE(a)|:\r\n\r\n % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\r\n\r\nNow I have responded by submitting a large number of purported 'solutions', some of which are _reasonably accurate_, and others which are either too imprecise or else logically flawed.  \r\n\r\nYour final Test Suite (contained within _your_ function |testSuite|) will have to address several aspects arising in your problem specification.  However, for this 'first draft' you are creating a naïve Test Suite with only one requirement:  \r\n\r\n# Check that my submitted code reliably returns *sufficiently accurate* values for sine of many different angles.  Use the \u003chttps://au.mathworks.com/help/matlab/ref/assert.html |assert|\u003e function to generate \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44357 errors/exceptions\u003e if the values are not sufficiently accurate.  \r\n\r\nYou *can* use the functions |sind|, |sin|, _etc._ in this draft Test Suite, if you want — even though this would be bad practice in your final Test Suite! \r\n\r\nThus, the above specification is merely a _starting point_.  You will develop more robust Test Suites in:\r\n\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44617 Problem 44617\u003e (part *1*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44616 Problem 44616\u003e (part *2*)\r\n* \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44521 Problem 44521\u003e (part *3*)","description_html":"\u003cp\u003e\u003ci\u003eHave no knowledge of \u003ca href = \"https://au.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html\"\u003e\"floating-point numbers\"\u003c/a\u003e?  Read the documentation, and/or try \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44690\"\u003eProblem 44690\u003c/a\u003e first.\u003c/i\u003e\u003c/p\u003e\u003cp\u003e——————————————————————————————————————————\u003c/p\u003e\u003cp\u003eIn this task you need to imagine that you — \u003ci\u003eyes, YOU\u003c/i\u003e — have developed a problem on Cody for \u003ci\u003eme\u003c/i\u003e to solve, and now \u003cb\u003eyou need to draft a naïve Test Suite\u003c/b\u003e as the first step in developing a more robust Test Suite that would check whether \u003ci\u003emy\u003c/i\u003e submitted solutions meet \u003ci\u003eyour\u003c/i\u003e requirements or not.\u003c/p\u003e\u003cp\u003eSo the tables are turned!  You are now in the role of Tester!  I am in the role of Player!\u003c/p\u003e\u003cp\u003eThe problem you've set me is to:\u003c/p\u003e\u003cul\u003e\u003cli\u003eoutput the \u003cb\u003esine\u003c/b\u003e of an angle, when the angle is specified in degrees as a (scalar) \u003ca href = \"https://au.mathworks.com/help/matlab/ref/double.html\"\u003e\u003ctt\u003edouble\u003c/tt\u003e\u003c/a\u003e, with no restriction in the domain.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou provide me with the following example for the function defined as \u003ctt\u003es = SINE(a)\u003c/tt\u003e:\u003c/p\u003e\u003cpre\u003e % INPUT\r\n a = 45 % degrees\r\n % OUTPUT\r\n s = 1/sqrt(2)\u003c/pre\u003e\u003cp\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are \u003ci\u003ereasonably accurate\u003c/i\u003e, and others which are either too imprecise or else logically flawed.\u003c/p\u003e\u003cp\u003eYour final Test Suite (contained within \u003ci\u003eyour\u003c/i\u003e function \u003ctt\u003etestSuite\u003c/tt\u003e) will have to address several aspects arising in your problem specification.  However, for this 'first draft' you are creating a naïve Test Suite with only one requirement:\u003c/p\u003e\u003col\u003e\u003cli\u003eCheck that my submitted code reliably returns \u003cb\u003esufficiently accurate\u003c/b\u003e values for sine of many different angles.  Use the \u003ca href = \"https://au.mathworks.com/help/matlab/ref/assert.html\"\u003e\u003ctt\u003eassert\u003c/tt\u003e\u003c/a\u003e function to generate \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44357\"\u003eerrors/exceptions\u003c/a\u003e if the values are not sufficiently accurate.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eYou \u003cb\u003ecan\u003c/b\u003e use the functions \u003ctt\u003esind\u003c/tt\u003e, \u003ctt\u003esin\u003c/tt\u003e, \u003ci\u003eetc.\u003c/i\u003e in this draft Test Suite, if you want — even though this would be bad practice in your final Test Suite!\u003c/p\u003e\u003cp\u003eThus, the above specification is merely a \u003ci\u003estarting point\u003c/i\u003e.  You will develop more robust Test Suites in:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44617\"\u003eProblem 44617\u003c/a\u003e (part \u003cb\u003e1\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44616\"\u003eProblem 44616\u003c/a\u003e (part \u003cb\u003e2\u003c/b\u003e)\u003c/li\u003e\u003cli\u003e\u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44521\"\u003eProblem 44521\u003c/a\u003e (part \u003cb\u003e3\u003c/b\u003e)\u003c/li\u003e\u003c/ul\u003e","function_template":"function dummy = testSuite()\r\n    \r\n    % Check outputs of submitted SINE function for various input values\r\n    % RATIONALE:  Computing SINE requires relatively simple code, \r\n    %             as the focus in the present task is on implementing a robust Test Suite.  \r\n    % MOTIVATION:  I could be submitting lazy code that only works for \r\n    %              a small number of angles, if that's all you test.\r\n    \r\n    %% Test 1\r\n    assert( isequal( SINE(45), 1/sqrt(2) )  )\r\n    \r\n    %% Test 2\r\n    assert( isequal( SINE(45), sine(45) )  )\r\n    \r\n    %% Test 3\r\n    assert( isequal( SINE(45), sin(45) )  )\r\n    \r\n    %% Test 4\r\n    assert( isequal( SINE(45), sind(45) )  )\r\n\r\n    %% Test 5\r\n    assert( isequal( SINE(45), sine(1/sqrt(2)) )  )\r\n    \r\n    %% Test 6\r\n    assert( isequal( SINE(45), sin(1/sqrt(2)) )  )\r\n    \r\n    %% Test 7\r\n    assert( isequal( SINE(45), sind(1/sqrt(2)) )  )\r\n    \r\n\r\nend\r\n\r\n%{\r\nNOTE:  \r\nThe text \"dummy = \" was added to this Function Template, \r\nbecause Cody was generating a spurious error, namely\r\n        Your problem cannot be published until you:\r\n        •Edit the function name in the test suite to match the function name in the function template\r\nHowever, in the Reference Solution it was confirmed to be unnecessary.  \r\n%}","test_suite":"%% Placeholder\r\n%assessFunctionAbsence('sind', 'FileName','testSuite.m')\r\n\r\n\r\n%% Exactly right\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\n                    testSuite()\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * pi / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = 1 ./ cscd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'pass';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * 3.14 / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Insufficiently close (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sin(angle * (22/7) / 180);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Sufficiently close (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle + 10000*eps(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Completely wrong\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = cosd(angle);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (I)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (II)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = -sind(angle*sign(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% Partly wrong (III)\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(angle)*sign(sind(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Fixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   s = sind(fix(angle));\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n\r\n\r\n%% 'Unfixed' angles\r\nfileID = fopen('SINE.m','w');\r\nfprintf(fileID,'function s = SINE(angle)\\n');\r\nfprintf(fileID,'   inc=0;\\n');\r\nfprintf(fileID,'   if mod(angle,1)==0, inc=1; end;\\n');\r\nfprintf(fileID,'   s = sind(angle + inc);\\n');\r\nfclose(fileID);\r\nstatus_correct = 'fail';\r\nstatus = 'pass';\r\ntry\r\n    testSuite()\r\ncatch e\r\n    status = 'fail'\r\nend\r\nassert( isequal(status, status_correct) , 'Wrong status' )\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":6,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-05T12:36:47.000Z","updated_at":"2018-06-17T02:29:04.000Z","published_at":"2018-05-05T13:35:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHave no knowledge of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e\\\"floating-point numbers\\\"\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e? Read the documentation, and/or try\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44690\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eProblem 44690\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e first.\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——————————————————————————————————————————\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\u003eIn this task you need to imagine that you —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyes, YOU\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — have developed a problem on Cody for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eme\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to solve, and now\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyou need to draft a naïve Test Suite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as the first step in developing a more robust Test Suite that would check whether\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e submitted solutions meet\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e requirements or not.\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\u003eSo the tables are turned! You are now in the role of Tester! I am in the role of Player!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe problem you've set me is to:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eoutput the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esine\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e of an angle, when the angle is specified in degrees as a (scalar)\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://au.mathworks.com/help/matlab/ref/double.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, with no restriction in the domain.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou provide me with the following example for the function defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es = SINE(a)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % INPUT\\n a = 45 % degrees\\n % OUTPUT\\n s = 1/sqrt(2)]]\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\u003eNow I have responded by submitting a large number of purported 'solutions', some of which are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ereasonably accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and others which are either too imprecise or else logically flawed.\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\u003eYour final Test Suite (contained within\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eyour\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etestSuite\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) will have to address several aspects arising in your problem specification. However, for this 'first draft' you are creating a naïve Test Suite with only one requirement:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck that my submitted code reliably returns\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esufficiently accurate\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e values for sine of many different angles. Use the\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://au.mathworks.com/help/matlab/ref/assert.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eassert\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e function to generate\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/44357\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eerrors/exceptions\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e if the values are not sufficiently accurate.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecan\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use the functions\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esin\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eetc.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in this draft Test Suite, if you want — even though this would be bad practice in your final Test Suite!\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\u003eThus, the above specification is merely a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estarting point\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. You will develop more robust Test Suites in:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44617\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44617\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44616\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44616\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44521\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 44521\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (part\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\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":44655,"title":"Computational power of Cody servers","description":"It has been \u003chttps://en.wikipedia.org/wiki/Moore%27s_law#History predicted\u003e that the performance of integrated circuits would _double_ every 18 months.  That suggests the time to perform a given computation should _halve_ roughly every 18 months.  \r\n\r\nWhat about on Cody?  Observational data is available from the final test case of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/963-we-love-vectorized-solutions-problem-1-remove-the-row-average Problem 963\u003e to help us quantify the improvement in performance!  And thereby even make predictions for future computations.\r\n\r\n Solution    Date\t   Runtime [s]\r\n ...\r\n 144393\t     04-Oct-12\t   4.230\r\n ...\r\n 654812\t     17-Apr-15\t   3.099\r\n ...\r\n 1272817     20-Sep-17\t   2.0402\r\n ...\r\n\r\nThe complete data set will be provided to you as input.  You should assume the general trend can be described by the following law:\r\n\r\n runtime = r0 - δ [1 - exp(-t/k)]\r\n runtime = r∞ + δ exp(-t/k)\r\n\r\nwhere |r0| is the runtime at the start of the period in seconds, |r∞| is the predicted runtime (in seconds) that will be approached far in the future, |δ = r0 - r∞|, and |t| is the time in nominal years since the start of the period, and |k| is a kinetic parameter (in nominal years).  \r\n\r\nThe start of the period is defined by the earliest date in the series.  Compute the number of days exactly, and assume that a nominal year comprises 365.24 days.\r\n\r\nYour task is to \u003chttps://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html fit the curve\u003e and thereby predict the runtime for various future dates.  Your output should be rounded to four decimal places.  \r\n\r\nMETHOD:  You _must_ use \u003chttps://au.mathworks.com/help/matlab/ref/fminsearch.html |fminsearch|\u003e to perform the non-linear regression, and you _must_ set the options using \u003chttps://au.mathworks.com/help/matlab/ref/optimset.html |optimset|\u003e to ensure sufficient accuracy.  The 'best' fit is defined — _for this problem, as in the common convention_ — as that which minimises the sum of the squares of the residuals.  \r\n\r\nEXAMPLE:\r\n\r\n % Input\r\n futureDate = '21-Nov-2023';\r\n data.solutionNumber = [1036949, ..., 1272817];\r\n data.date = ['29-Oct-2016'; ...; '20-Sep-2017'];\r\n data.runtime = [1.2630, ..., 2.0402];\r\n % Output\r\n predictedRuntime = 0.3619;  % seconds\r\n\r\n","description_html":"\u003cp\u003eIt has been \u003ca href = \"https://en.wikipedia.org/wiki/Moore%27s_law#History\"\u003epredicted\u003c/a\u003e that the performance of integrated circuits would \u003ci\u003edouble\u003c/i\u003e every 18 months.  That suggests the time to perform a given computation should \u003ci\u003ehalve\u003c/i\u003e roughly every 18 months.\u003c/p\u003e\u003cp\u003eWhat about on Cody?  Observational data is available from the final test case of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/963-we-love-vectorized-solutions-problem-1-remove-the-row-average\"\u003eProblem 963\u003c/a\u003e to help us quantify the improvement in performance!  And thereby even make predictions for future computations.\u003c/p\u003e\u003cpre\u003e Solution    Date\t   Runtime [s]\r\n ...\r\n 144393\t     04-Oct-12\t   4.230\r\n ...\r\n 654812\t     17-Apr-15\t   3.099\r\n ...\r\n 1272817     20-Sep-17\t   2.0402\r\n ...\u003c/pre\u003e\u003cp\u003eThe complete data set will be provided to you as input.  You should assume the general trend can be described by the following law:\u003c/p\u003e\u003cpre\u003e runtime = r0 - δ [1 - exp(-t/k)]\r\n runtime = r∞ + δ exp(-t/k)\u003c/pre\u003e\u003cp\u003ewhere \u003ctt\u003er0\u003c/tt\u003e is the runtime at the start of the period in seconds, \u003ctt\u003er∞\u003c/tt\u003e is the predicted runtime (in seconds) that will be approached far in the future, \u003ctt\u003eδ = r0 - r∞\u003c/tt\u003e, and \u003ctt\u003et\u003c/tt\u003e is the time in nominal years since the start of the period, and \u003ctt\u003ek\u003c/tt\u003e is a kinetic parameter (in nominal years).\u003c/p\u003e\u003cp\u003eThe start of the period is defined by the earliest date in the series.  Compute the number of days exactly, and assume that a nominal year comprises 365.24 days.\u003c/p\u003e\u003cp\u003eYour task is to \u003ca href = \"https://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html\"\u003efit the curve\u003c/a\u003e and thereby predict the runtime for various future dates.  Your output should be rounded to four decimal places.\u003c/p\u003e\u003cp\u003eMETHOD:  You \u003ci\u003emust\u003c/i\u003e use \u003ca href = \"https://au.mathworks.com/help/matlab/ref/fminsearch.html\"\u003e\u003ctt\u003efminsearch\u003c/tt\u003e\u003c/a\u003e to perform the non-linear regression, and you \u003ci\u003emust\u003c/i\u003e set the options using \u003ca href = \"https://au.mathworks.com/help/matlab/ref/optimset.html\"\u003e\u003ctt\u003eoptimset\u003c/tt\u003e\u003c/a\u003e to ensure sufficient accuracy.  The 'best' fit is defined — \u003ci\u003efor this problem, as in the common convention\u003c/i\u003e — as that which minimises the sum of the squares of the residuals.\u003c/p\u003e\u003cp\u003eEXAMPLE:\u003c/p\u003e\u003cpre\u003e % Input\r\n futureDate = '21-Nov-2023';\r\n data.solutionNumber = [1036949, ..., 1272817];\r\n data.date = ['29-Oct-2016'; ...; '20-Sep-2017'];\r\n data.runtime = [1.2630, ..., 2.0402];\r\n % Output\r\n predictedRuntime = 0.3619;  % seconds\u003c/pre\u003e","function_template":"function predictedRuntime = predictor(futureDate, data)\r\n    % Preliminaries:\r\n    ...\r\n    \r\n    \r\n    % Use fminsearch to find the parameters that minimize the objective function.\r\n    myObjectiveFun = ...\r\n    myOptions = ...\r\n    ... = fminsearch\r\n\r\n    % Report your prediction of the runtime at the specified future date.\r\n    predictedRuntime = ...\r\nend\r\n\r\n% Function that accepts a trial set of parameters and the observed data, \r\n% and returns the sum of squared errors for the model . \r\n% https://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html\r\nfunction SSE = sseVal(...)\r\n    % runtime = r0 - δ [1 - exp(-t/k)]\r\n    % runtime = r∞ + δ exp(-t/k)\r\n    \r\n    ...\r\n    \r\n    SSE = ...\r\nend\r\n","test_suite":"data.solutionNumber = [1036949\t1048171\t1051202\t1078061\t1078699\t1081561\t886761\t1165117\t1202850\t1211446\t1241478\t1241530\t1329044\t1323931\t1382633\t1345204\t1281524\t1272814\t1272815\t1272823\t1272845\t1287012\t1287386\t1262442\t1262445\t1251993\t1252843\t1407137\t1412687\t1448359\t1448368\t1410187\t1465616\t1472214\t1472225\t1490596\t1490602\t1541085\t1541132\t860114\t143879\t144156\t144393\t202249\t210894\t539555\t182974\t276887\t1133109\t654812\t1272817];\r\ndata.date = ['29-Oct-2016';\t'08-Nov-2016';\t'12-Nov-2016';\t'09-Dec-2016';\t'10-Dec-2016';\t'14-Dec-2016';\t'06-May-2016';\t'18-Apr-2017';\t'02-Jun-2017';\t'13-Jun-2017';\t'28-Jul-2017';\t'28-Jul-2017';\t'06-Nov-2017';\t'01-Nov-2017';\t'16-Dec-2017';\t'15-Nov-2017';\t'05-Oct-2017';\t'20-Sep-2017';\t'20-Sep-2017';\t'20-Sep-2017';\t'20-Sep-2017';\t'15-Oct-2017';\t'15-Oct-2017';\t'05-Sep-2017';\t'05-Sep-2017';\t'16-Aug-2017';\t'17-Aug-2017';\t'06-Jan-2018';\t'10-Jan-2018';\t'24-Feb-2018';\t'24-Feb-2018';\t'08-Jan-2018';\t'18-Mar-2018';\t'27-Mar-2018';\t'27-Mar-2018';\t'13-Apr-2018';\t'13-Apr-2018';\t'26-May-2018';\t'26-May-2018';\t'31-Mar-2016';\t'02-Oct-2012';\t'03-Oct-2012';\t'04-Oct-2012';\t'08-Feb-2013';\t'01-Mar-2013';\t'03-Dec-2014';\t'29-Dec-2012';\t'09-Jul-2013';\t'03-Mar-2017';\t'17-Apr-2015';\t'20-Sep-2017'];\r\ndata.runtime = [1.2630\t0.624\t1.3326\t1.2939\t0.5995\t1.1307\t1.3505\t1.2613\t1.2737\t1.3081\t1.2774\t1.252\t1.2179\t1.4431\t1.2637\t1.1614\t1.2542\t1.9135\t1.2996\t1.2595\t1.2664\t1.1858\t1.1501\t1.2516\t1.2786\t1.9461\t1.2492\t1.3654\t1.3263\t1.1484\t1.1728\t1.6177\t1.0538\t1.0571\t1.0454\t1.3873\t1.0600\t1.1154\t1.0635\t1.4359\t4.498\t4.198\t4.230\t5.264\t4.022\t3.153\t4.740\t4.112\t2.3409\t3.099\t2.0402];\r\n\r\n%% Anti-hacking provision\r\n% ADDED 2019-06-29.  \r\n% Ensure only builtin functions will be called.  \r\n! rm -v fileread.m\r\n! rm -v assert.m\r\n\r\n%% Required methodology\r\nassessFunctionPresence({'fminsearch', 'optimset'}, 'FileName','predictor.m', 'Feedback','You must use the specified methodology')\r\n\r\n%% Anti-hardcoding test\r\n% Adapted from a comment at https://www.mathworks.com/matlabcentral/cody/problems/44343 .\r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[2012,2019:2023,3000]),regexp(fileread('predictor.m'),'[\\d\\.\\+\\-\\*\\/\\(\\) \\[\\]\\,\\;]+','match'))), 'Please don''t hard-code your ''solution''.') \r\nassert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[2012,2019:2023,3000]),regexp(fileread('predictor.m'),'\\d+','match'))), 'Please do not hard-code your ''solution''.') \r\n\r\n%% January 2019\r\nfutureDate = '22-Jan-2019';\r\npredictedRuntime_correct = round(0.935043294718475, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '23-Jan-2019';\r\npredictedRuntime_correct = round(0.934448955935569, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '24-Jan-2019';\r\npredictedRuntime_correct = round(0.933855075296061, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% January 2020\r\nfutureDate = '09-Jan-2020';\r\npredictedRuntime_correct = round(0.751755426901932, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '13-Jan-2020';\r\npredictedRuntime_correct = round(0.749945312632780, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% January 2021\r\nfutureDate = '06-Jan-2021';\r\npredictedRuntime_correct = round(0.608254613313523, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '11-Jan-2021';\r\npredictedRuntime_correct = round(0.606545074994730, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% February 2022\r\nfutureDate = '06-Feb-2022';\r\npredictedRuntime_correct = round(0.491354117473879, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '10-Feb-2022';\r\npredictedRuntime_correct = round(0.490345992043568, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% November 2023\r\nfutureDate = '06-Nov-2023';\r\npredictedRuntime_correct = round(0.364155581026111, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '21-Nov-2023';\r\npredictedRuntime_correct = round(0.361853937995679, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '25-Nov-2023';\r\npredictedRuntime_correct = round(0.361244649648014, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\nfutureDate = '27-Nov-2023';\r\npredictedRuntime_correct = round(0.360940709522436, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% Let's all meet up in the year 3000\r\nfutureDate = '01-Jan-3000';\r\npredictedRuntime_correct = round(0.164021404839, 4);\r\nassert(isequal(predictor(futureDate, data), predictedRuntime_correct))\r\n\r\n%% Enforce antihacking\r\n% Assure no 'workarounds' that avoid appropriate use of optimset.\r\n% (Added 29 May 2018.)\r\nfutureDate = {'19-Dec-2019';\t'04-Oct-2020';\t'06-Nov-2020';\t'20-Nov-2020';\t'07-Dec-2020';\t'09-Dec-2020';\t'11-Dec-2020';\t'25-Feb-2021';\t'04-Mar-2021';\t'18-Apr-2021';\t'19-May-2021';\t'23-Jul-2021'};\r\npRuntime_c_unrounded = {0.761350673860113\t0.641651747331991\t0.629650497697623\t0.624650604424140\t0.618651428148657\t0.617950799242008\t0.617251250072375\t0.591452258418511\t0.589151203003048\t0.574651625923890\t0.564951737257372\t0.545350739105932};\r\nfor j = 1 : length(futureDate)\r\n    assert(isequal(predictor(futureDate{j}, data), round(pRuntime_c_unrounded{j}, 4)))\r\nend;\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":64439,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":"2019-06-29T12:58:19.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2018-05-27T08:32:09.000Z","updated_at":"2019-06-29T12:58:19.000Z","published_at":"2018-05-27T12:35:16.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\u003eIt has been\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://en.wikipedia.org/wiki/Moore%27s_law#History\\\"\u003e\u003cw:r\u003e\u003cw:t\u003epredicted\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e that the performance of integrated circuits would\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edouble\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e every 18 months. That suggests the time to perform a given computation should\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ehalve\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e roughly every 18 months.\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\u003eWhat about on Cody? Observational data is available from the final test case 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/963-we-love-vectorized-solutions-problem-1-remove-the-row-average\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 963\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to help us quantify the improvement in performance! And thereby even make predictions for future computations.\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[ Solution    Date     Runtime [s]\\n ...\\n 144393       04-Oct-12     4.230\\n ...\\n 654812       17-Apr-15     3.099\\n ...\\n 1272817     20-Sep-17     2.0402\\n ...]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe complete data set will be provided to you as input. You should assume the general trend can be described by the following law:\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[ runtime = r0 - δ [1 - exp(-t/k)]\\n runtime = r∞ + δ exp(-t/k)]]\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\u003ewhere\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003er0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the runtime at the start of the period in seconds,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003er∞\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the predicted runtime (in seconds) that will be approached far in the future,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eδ = r0 - r∞\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003et\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the time in nominal years since the start of the period, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is a kinetic parameter (in nominal years).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe start of the period is defined by the earliest date in the series. Compute the number of days exactly, and assume that a nominal year comprises 365.24 days.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour task is to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://au.mathworks.com/help/matlab/math/example-curve-fitting-via-optimization.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003efit the curve\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and thereby predict the runtime for various future dates. Your output should be rounded to four decimal places.\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\u003eMETHOD: You\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emust\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e use\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://au.mathworks.com/help/matlab/ref/fminsearch.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efminsearch\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to perform the non-linear regression, and you\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emust\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e set the options using\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://au.mathworks.com/help/matlab/ref/optimset.html\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eoptimset\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e to ensure sufficient accuracy. The 'best' fit is defined —\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efor this problem, as in the common convention\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e — as that which minimises the sum of the squares of the residuals.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEXAMPLE:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ % Input\\n futureDate = '21-Nov-2023';\\n data.solutionNumber = [1036949, ..., 1272817];\\n data.date = ['29-Oct-2016'; ...; '20-Sep-2017'];\\n data.runtime = [1.2630, ..., 2.0402];\\n % Output\\n predictedRuntime = 0.3619;  % seconds]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"meta-problem\"","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:\"meta-problem\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"meta-problem\"","","\"","meta-problem","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f1022598218\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f1022598178\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f10225978b8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f1022598498\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f10225983f8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f1022598358\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f10225982b8\u003e":"tag:\"meta-problem\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f10225982b8\u003e":"tag:\"meta-problem\""},"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":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"meta-problem\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"meta-problem\"","","\"","meta-problem","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f1022598218\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f1022598178\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f10225978b8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f1022598498\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f10225983f8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f1022598358\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f10225982b8\u003e":"tag:\"meta-problem\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f10225982b8\u003e":"tag:\"meta-problem\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2530,"difficulty_rating":"easy-medium"},{"id":44521,"difficulty_rating":"medium"},{"id":44616,"difficulty_rating":"medium"},{"id":44617,"difficulty_rating":"medium"},{"id":44631,"difficulty_rating":"medium"},{"id":44655,"difficulty_rating":"unrated"}]}}