{"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":1098,"title":"USC Fall 2012 ACM : Code Word Minimum Flipped Bits","description":"This Challenge is to solve Question A of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nGiven an array M of Valid binary codewords(m codewords of width n) and a Received Corrupted(?) codeword of width n, determine the minimum number of flipped bits in the Received codeword to generate a valid codeword.\r\n\r\n\r\nInput: [ M, v ]\r\n\r\nOutput: e, minimum number of error(flipped) bits\r\n.\r\n\r\nFrom full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=codes.in.txt USC data file\u003e\r\n\r\nInput: [0 0 0; 1 1 1; 1 1 0], [0 1 0]\r\n\r\nOutput: 1 as [0 1 0] can convert to [0 0 0] or [1 1 0] with a single flip\r\n\r\nMatlab one-liner?\r\n\r\nThe Winning C solution - not much help:\r\n\r\n  #include \u003ciostream\u003e\r\n  #include \u003cstdio.h\u003e\r\n  #include \u003cstring\u003e\r\n  using namespace std;\r\n  int main () {\r\n  \tfreopen(\"codes.in\", \"r\", stdin);\r\n  \tint K,n,b;\r\n  \tcin \u003e\u003e K;\r\n  \tfor (int i = 1; i \u003c K + 1; ++i) {\r\n  \t\tcin \u003e\u003e n \u003e\u003e b;\r\n  \t\tstring m[1000], r;\r\n  \t\tfor (int j = 0; j \u003c n; ++j)\r\n  \t\t\tcin \u003e\u003e m[j];\r\n  \t\tcin \u003e\u003e r;\r\n% Process Start\t\t\r\n  \t\tint f = b;\r\n  \t\tfor (int j = 0; j \u003c n; ++j) {\r\n  \t\t\tint d = b;\r\n  \t\t\tfor (int k = 0; k \u003c b; ++k) {\r\n  \t\t\t\tif (m[j][k] == r[k])\r\n  \t\t\t\t\t--d;\r\n  \t\t\t}\r\n  \t\t\tf = ((f \u003c= d) ? f : d);\r\n  \t\t}\r\n % Process End \r\n  \t\tprintf(\"Data Set %d:\\n\", i);\r\n  \t\tprintf(\"%d\\n\\n\", f);\r\n  \t}\r\n  \treturn 0;\r\n  }\r\n  ","description_html":"\u003cp\u003eThis Challenge is to solve Question A of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGiven an array M of Valid binary codewords(m codewords of width n) and a Received Corrupted(?) codeword of width n, determine the minimum number of flipped bits in the Received codeword to generate a valid codeword.\u003c/p\u003e\u003cp\u003eInput: [ M, v ]\u003c/p\u003e\u003cp\u003eOutput: e, minimum number of error(flipped) bits\r\n.\u003c/p\u003e\u003cp\u003eFrom full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=codes.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInput: [0 0 0; 1 1 1; 1 1 0], [0 1 0]\u003c/p\u003e\u003cp\u003eOutput: 1 as [0 1 0] can convert to [0 0 0] or [1 1 0] with a single flip\u003c/p\u003e\u003cp\u003eMatlab one-liner?\u003c/p\u003e\u003cp\u003eThe Winning C solution - not much help:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e#include \u0026lt;iostream\u003e\r\n#include \u0026lt;stdio.h\u003e\r\n#include \u0026lt;string\u003e\r\nusing namespace std;\r\nint main () {\r\n\tfreopen(\"codes.in\", \"r\", stdin);\r\n\tint K,n,b;\r\n\tcin \u003e\u003e K;\r\n\tfor (int i = 1; i \u0026lt; K + 1; ++i) {\r\n\t\tcin \u003e\u003e n \u003e\u003e b;\r\n\t\tstring m[1000], r;\r\n\t\tfor (int j = 0; j \u0026lt; n; ++j)\r\n\t\t\tcin \u003e\u003e m[j];\r\n\t\tcin \u003e\u003e r;\r\n% Process Start\t\t\r\n\t\tint f = b;\r\n\t\tfor (int j = 0; j \u0026lt; n; ++j) {\r\n\t\t\tint d = b;\r\n\t\t\tfor (int k = 0; k \u0026lt; b; ++k) {\r\n\t\t\t\tif (m[j][k] == r[k])\r\n\t\t\t\t\t--d;\r\n\t\t\t}\r\n\t\t\tf = ((f \u0026lt;= d) ? f : d);\r\n\t\t}\r\n% Process End \r\n\t\tprintf(\"Data Set %d:\\n\", i);\r\n\t\tprintf(\"%d\\n\\n\", f);\r\n\t}\r\n\treturn 0;\r\n}\r\n\u003c/pre\u003e","function_template":"function f = USC_No_1(M,v)\r\n  f=0;\r\nend","test_suite":"%%\r\ntic\r\nurlfn='http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=codes.in.txt';\r\nurlwrite(urlfn,'codesin_A.txt'); % Load file from USC\r\ntoc\r\n%%\r\n flip_correct=[1 0 0 54 1 29 37 32 33 32 39 8 0 0 36 36 35];\r\n\r\n fid=fopen('codesin_A.txt','r');\r\n\r\n qty=fscanf(fid,'%i',1);\r\n for ptr=1:qty\r\n  nr=fscanf(fid,'%i',1);\r\n  nc=fscanf(fid,'%i',1);\r\n \r\n  A=zeros(nr,nc);\r\n  for i=1:nr\r\n   strv=fscanf(fid,'%s',1); % Reads a line of text\r\n   A(i,:)=strv-'0'; % vectorize the string\r\n  end\r\n \r\n  strv=fscanf(fid,'%s',1);\r\n  v=strv-'0';\r\n\r\n  USC_flips = USC_No_1(A,v);\r\n\r\n  assert(isequal(USC_flips,flip_correct(ptr)))\r\n \r\n end\r\n fclose(fid);\r\n \r\ntoc\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-06T02:14:30.000Z","updated_at":"2024-11-05T12:53:23.000Z","published_at":"2012-12-06T02:40:27.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\u003eThis Challenge is to solve Question A of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an array M of Valid binary codewords(m codewords of width n) and a Received Corrupted(?) codeword of width n, determine the minimum number of flipped bits in the Received codeword to generate a valid codeword.\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\u003eInput: [ M, v ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: e, minimum number of error(flipped) bits .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFrom full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=codes.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eInput: [0 0 0; 1 1 1; 1 1 0], [0 1 0]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: 1 as [0 1 0] can convert to [0 0 0] or [1 1 0] with a single flip\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\u003eMatlab one-liner?\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 Winning C solution - not much help:\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[#include \u003ciostream\u003e\\n#include \u003cstdio.h\u003e\\n#include \u003cstring\u003e\\nusing namespace std;\\nint main () {\\n  freopen(\\\"codes.in\\\", \\\"r\\\", stdin);\\n  int K,n,b;\\n  cin \u003e\u003e K;\\n  for (int i = 1; i \u003c K + 1; ++i) {\\n    cin \u003e\u003e n \u003e\u003e b;\\n    string m[1000], r;\\n    for (int j = 0; j \u003c n; ++j)\\n      cin \u003e\u003e m[j];\\n    cin \u003e\u003e r;\\n% Process Start    \\n    int f = b;\\n    for (int j = 0; j \u003c n; ++j) {\\n      int d = b;\\n      for (int k = 0; k \u003c b; ++k) {\\n        if (m[j][k] == r[k])\\n          --d;\\n      }\\n      f = ((f \u003c= d) ? f : d);\\n    }\\n% Process End \\n    printf(\\\"Data Set %d:\\\\n\\\", i);\\n    printf(\\\"%d\\\\n\\\\n\\\", f);\\n  }\\n  return 0;\\n}]]\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":1457,"title":"USC Spring 2013 ACM: Walking on Thin Ice","description":"This Challenge is to solve the \u003chttp://contest.usc.edu/index.php/Spring13/Home USC Spring 2013 ACM Contest\u003e Problem E, Walking on Thin Ice.\r\n\r\nThe Rooster is crossing to the other side of the frozen river. Minimize his distance traveled on thin ice given a river width (w) and polygons(polycell) that denote non-thin ice regions. Start anywhere on the x-axis(y=0) and finish by reaching y=w.\r\n\r\n*Input:* \r\n\r\nw=120 \r\n\r\npolycell={[0 10 0 90 50 50 100 90 100 10] [0 110 100 110 50 70]};\r\n\r\n*Output:* 35.6174  \r\n\r\nThe only USC competition solver(45 minutes): \u003chttp://contest.usc.edu/index.php/Spring13/Home?action=download\u0026upname=thinice.zhengcao.cpp.txt Cao's C solution\u003e\r\n\r\n*Theory:*\r\n\r\nTraveling Salesman Optimum Route. (Matlab one line while)\r\n\r\nCreate Interconnect Matrix\r\n\r\nCalculate Route/Distances between Good-Ice using Polygon to Polygon distance function.\r\n\r\nPolygon to Polygon minimum distance uses minimum Point to Line Segment function.\r\n\r\n\r\n*Related Challenges:*\r\n\r\n1) \u003chttp://www.mathworks.com/matlabcentral/cody/problems/1446-minimum-distance-point-to-segment Minimum Distance Point to Segment\u003e\r\n\r\n2) \u003chttp://www.mathworks.com/matlabcentral/cody/problems/1452-minimum-distance-between-two-n-sided-polygons Minimum Distance between Polygons\u003e","description_html":"\u003cp\u003eThis Challenge is to solve the \u003ca href = \"http://contest.usc.edu/index.php/Spring13/Home\"\u003eUSC Spring 2013 ACM Contest\u003c/a\u003e Problem E, Walking on Thin Ice.\u003c/p\u003e\u003cp\u003eThe Rooster is crossing to the other side of the frozen river. Minimize his distance traveled on thin ice given a river width (w) and polygons(polycell) that denote non-thin ice regions. Start anywhere on the x-axis(y=0) and finish by reaching y=w.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e\u003c/p\u003e\u003cp\u003ew=120\u003c/p\u003e\u003cp\u003epolycell={[0 10 0 90 50 50 100 90 100 10] [0 110 100 110 50 70]};\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e 35.6174\u003c/p\u003e\u003cp\u003eThe only USC competition solver(45 minutes): \u003ca href = \"http://contest.usc.edu/index.php/Spring13/Home?action=download\u0026upname=thinice.zhengcao.cpp.txt\"\u003eCao's C solution\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eTheory:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eTraveling Salesman Optimum Route. (Matlab one line while)\u003c/p\u003e\u003cp\u003eCreate Interconnect Matrix\u003c/p\u003e\u003cp\u003eCalculate Route/Distances between Good-Ice using Polygon to Polygon distance function.\u003c/p\u003e\u003cp\u003ePolygon to Polygon minimum distance uses minimum Point to Line Segment function.\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e1) \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/1446-minimum-distance-point-to-segment\"\u003eMinimum Distance Point to Segment\u003c/a\u003e\u003c/p\u003e\u003cp\u003e2) \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/1452-minimum-distance-between-two-n-sided-polygons\"\u003eMinimum Distance between Polygons\u003c/a\u003e\u003c/p\u003e","function_template":"function d=Thin_Ice(w,polycell)\r\n d=0;\r\n% pr=reshape(polycell{1},2,[])'; % example of first matrix to [x,y]\r\nend","test_suite":"tic\r\nw=50+randi(100,1) % case random 1 15\r\npymax=randi(50,1)\r\npolycell={[0 0 10 pymax 20 0]}; % case 1 15\r\nd=Thin_Ice(w,polycell)\r\nassert(abs(d-(w-pymax))\u003c.01)\r\ntoc\r\n%%\r\ntic\r\nw=110+randi(100,1); % case random 2\r\nw\r\npymax1=randi(30,1)\r\npymax2=randi(10,1)\r\npymax3=randi(10,1)\r\npolycell={[0 0 10 pymax1 pymax3 0] [-pymax2 30+pymax2 20+pymax1 30+pymax2 pymax1 40+pymax3]}; % case random\r\nd=Thin_Ice(w,polycell)\r\nassert(abs(d-(w-pymax1-(40+pymax3-(30+pymax2))))\u003c.01)\r\ntoc\r\n%%\r\n\r\ntic\r\nw=100; % case 1 15\r\npolycell={[0 0 10 85 20 0]}; % case 1 15\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-15)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=10; %case 2 5\r\npolycell={[-2 0 -2 2 2 2 2 0] [-2 5 -2 8 2 8 2 5]}; \r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-5)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=3618;% case 3 3598\r\npolycell={[550 201 546 211 555 221 564 211 560 201]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-3598)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=3618;% case 4 3593.57\r\npolycell={[550 201 546 211 555 221 564 211 560 201]...\r\n [570 211 566 221 575 231 584 221 580 211]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-3593.57)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=3618; % case 5 3598\r\npolycell={[550 201 546 211 555 221 564 211 560 201]...\r\n[1570 211 1566 221 1575 231 1584 221 1580 211]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-3598)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=10; %case 6 5\r\npolycell={[-2 0 -2 2 2 2 2 0]...\r\n[-10 5 -10 8 10 8 10 5]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-5)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=10000; %case 7 1615.15\r\npolycell={[-912000 8801 -912000 8881 -911001 8881 -911001 8801]...\r\n[-910000 9001 -910000 9087 -909001 9087 -909001 9001]...\r\n[ -993000 701 -993000 789 -992001 789 -992001 701]...\r\n[ -960000 4001 -960000 4082 -959001 4082 -959001 4001]...\r\n[ -984000 1601 -984000 1687 -983001 1687 -983001 1601]...\r\n[ -980000 2001 -980000 2089 -979001 2089 -979001 2001]...\r\n[ -942000 5801 -942000 5883 -941001 5883 -941001 5801]...\r\n[ -909000 9101 -909000 9185 -908001 9185 -908001 9101]...\r\n[ -967000 3301 -967000 3387 -966001 3387 -966001 3301]...\r\n[ -947000 5301 -947000 5382 -946001 5382 -946001 5301]...\r\n[ -908000 9201 -908000 9282 -907001 9282 -907001 9201]...\r\n[ -903000 9701 -903000 9781 -902001 9781 -902001 9701]...\r\n[ -951000 4901 -951000 4986 -950001 4986 -950001 4901]...\r\n[ -963000 3701 -963000 3788 -962001 3788 -962001 3701]...\r\n[ -973000 2701 -973000 2783 -972001 2783 -972001 2701]...\r\n[ -975000 2501 -975000 2584 -974001 2584 -974001 2501]...\r\n[ -994000 601 -994000 680 -993001 680 -993001 601]...\r\n[ -1000000 1 -1000000 86 -999001 86 -999001 1]...\r\n[ -999000 101 -999000 187 -998001 187 -998001 101]...\r\n[ -954000 4601 -954000 4686 -953001 4686 -953001 4601]...\r\n[ -930000 7001 -930000 7082 -929001 7082 -929001 7001]...\r\n[ -974000 2601 -974000 2680 -973001 2680 -973001 2601]...\r\n[ -926000 7401 -926000 7488 -925001 7488 -925001 7401]...\r\n[ -945000 5501 -945000 5583 -944001 5583 -944001 5501]...\r\n[ -956000 4401 -956000 4480 -955001 4480 -955001 4401]...\r\n[ -971000 2901 -971000 2987 -970001 2987 -970001 2901]...\r\n[ -933000 6701 -933000 6789 -932001 6789 -932001 6701]...\r\n[ -976000 2401 -976000 2482 -975001 2482 -975001 2401]...\r\n[ -970000 3001 -970000 3086 -969001 3086 -969001 3001]...\r\n[ -981000 1901 -981000 1989 -980001 1989 -980001 1901]...\r\n[ -955000 4501 -955000 4580 -954001 4580 -954001 4501]...\r\n[ -950000 5001 -950000 5088 -949001 5088 -949001 5001]...\r\n[ -906000 9401 -906000 9481 -905001 9481 -905001 9401]...\r\n[ -927000 7301 -927000 7386 -926001 7386 -926001 7301]...\r\n[ -911000 8901 -911000 8987 -910001 8987 -910001 8901]...\r\n[ -928000 7201 -928000 7282 -927001 7282 -927001 7201]...\r\n[ -996000 401 -996000 480 -995001 480 -995001 401]...\r\n[ -966000 3401 -966000 3483 -965001 3483 -965001 3401]...\r\n[ -925000 7501 -925000 7588 -924001 7588 -924001 7501]...\r\n[ -905000 9501 -905000 9587 -904001 9587 -904001 9501]...\r\n[ -943000 5701 -943000 5785 -942001 5785 -942001 5701]...\r\n[ -990000 1001 -990000 1087 -989001 1087 -989001 1001]...\r\n[ -948000 5201 -948000 5288 -947001 5288 -947001 5201]...\r\n[ -968000 3201 -968000 3281 -967001 3281 -967001 3201]...\r\n[ -989000 1101 -989000 1180 -988001 1180 -988001 1101]...\r\n[ -935000 6501 -935000 6587 -934001 6587 -934001 6501]...\r\n[ -936000 6401 -936000 6484 -935001 6484 -935001 6401]...\r\n[ -998000 201 -998000 283 -997001 283 -997001 201]...\r\n[ -932000 6801 -932000 6886 -931001 6886 -931001 6801]...\r\n[ -918000 8201 -918000 8282 -917001 8282 -917001 8201]...\r\n[ -916000 8401 -916000 8486 -915001 8486 -915001 8401]...\r\n[ -952000 4801 -952000 4880 -951001 4880 -951001 4801]...\r\n[ -992000 801 -992000 886 -991001 886 -991001 801]...\r\n[ -913000 8701 -913000 8786 -912001 8786 -912001 8701]...\r\n[ -901000 9901 -901000 9989 -900001 9989 -900001 9901]...\r\n[ -962000 3801 -962000 3887 -961001 3887 -961001 3801]...\r\n[ -902000 9801 -902000 9884 -901001 9884 -901001 9801]...\r\n[ -917000 8301 -917000 8384 -916001 8384 -916001 8301]...\r\n[ -985000 1501 -985000 1583 -984001 1583 -984001 1501]...\r\n[ -979000 2101 -979000 2188 -978001 2188 -978001 2101]...\r\n[ -940000 6001 -940000 6088 -939001 6088 -939001 6001]...\r\n[ -988000 1201 -988000 1282 -987001 1282 -987001 1201]...\r\n[ -904000 9601 -904000 9687 -903001 9687 -903001 9601]...\r\n[ -922000 7801 -922000 7885 -921001 7885 -921001 7801]...\r\n[ -929000 7101 -929000 7188 -928001 7188 -928001 7101]...\r\n[ -907000 9301 -907000 9389 -906001 9389 -906001 9301]...\r\n[ -997000 301 -997000 381 -996001 381 -996001 301]...\r\n[ -939000 6101 -939000 6181 -938001 6181 -938001 6101]...\r\n[ -983000 1701 -983000 1787 -982001 1787 -982001 1701]...\r\n[ -978000 2201 -978000 2285 -977001 2285 -977001 2201]...\r\n[ -944000 5601 -944000 5686 -943001 5686 -943001 5601]...\r\n[ -987000 1301 -987000 1382 -986001 1382 -986001 1301]...\r\n[ -986000 1401 -986000 1484 -985001 1484 -985001 1401]...\r\n[ -982000 1801 -982000 1887 -981001 1887 -981001 1801]...\r\n[ -934000 6601 -934000 6687 -933001 6687 -933001 6601]...\r\n[ -972000 2801 -972000 2884 -971001 2884 -971001 2801]...\r\n[ -938000 6201 -938000 6282 -937001 6282 -937001 6201]...\r\n[ -964000 3601 -964000 3685 -963001 3685 -963001 3601]...\r\n[ -915000 8501 -915000 8586 -914001 8586 -914001 8501]...\r\n[ -937000 6301 -937000 6383 -936001 6383 -936001 6301]...\r\n[ -919000 8101 -919000 8187 -918001 8187 -918001 8101]...\r\n[ -949000 5101 -949000 5186 -948001 5186 -948001 5101]...\r\n[ -953000 4701 -953000 4782 -952001 4782 -952001 4701]...\r\n[ -959000 4101 -959000 4188 -958001 4188 -958001 4101]...\r\n[ -961000 3901 -961000 3988 -960001 3988 -960001 3901]...\r\n[ -920000 8001 -920000 8088 -919001 8088 -919001 8001]...\r\n[ -931000 6901 -931000 6981 -930001 6981 -930001 6901]...\r\n[ -914000 8601 -914000 8686 -913001 8686 -913001 8601]...\r\n[ -924000 7601 -924000 7687 -923001 7687 -923001 7601]...\r\n[ -923000 7701 -923000 7789 -922001 7789 -922001 7701]...\r\n[ -965000 3501 -965000 3584 -964001 3584 -964001 3501]...\r\n[ -958000 4201 -958000 4280 -957001 4280 -957001 4201]...\r\n[ -991000 901 -991000 989 -990001 989 -990001 901]...\r\n[ -957000 4301 -957000 4383 -956001 4383 -956001 4301]...\r\n[ -969000 3101 -969000 3187 -968001 3187 -968001 3101]...\r\n[ -977000 2301 -977000 2388 -976001 2388 -976001 2301]...\r\n[ -946000 5401 -946000 5484 -945001 5484 -945001 5401]...\r\n[ -995000 501 -995000 589 -994001 589 -994001 501]...\r\n[ -921000 7901 -921000 7983 -920001 7983 -920001 7901]...\r\n[ -941000 5901 -941000 5981 -940001 5981 -940001 5901]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-1615.15)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=11000; % case 8 1536.76\r\npolycell={[-918919 8101 -918919 8197 -917920 8197 -917920 8101]...\r\n[ -965966 3401 -965966 3502 -964967 3502 -964967 3401]...\r\n[ -989990 1001 -989990 1126 -988991 1126 -988991 1001]...\r\n[ -940941 5901 -940941 5984 -939942 5984 -939942 5901]...\r\n[ -975976 2401 -975976 2489 -974977 2489 -974977 2401]...\r\n[ -968969 3101 -968969 3207 -967970 3207 -967970 3101]...\r\n[ -957958 4201 -957958 4296 -956959 4296 -956959 4201]...\r\n[ -970971 2901 -970971 3021 -969972 3021 -969972 2901]...\r\n[ -927928 7201 -927928 7325 -926929 7325 -926929 7201]...\r\n[ -956957 4301 -956957 4382 -955958 4382 -955958 4301]...\r\n[ -947948 5201 -947948 5296 -946949 5296 -946949 5201]...\r\n[ -988989 1101 -988989 1225 -987990 1225 -987990 1101]...\r\n[ -915916 8401 -915916 8497 -914917 8497 -914917 8401]...\r\n[ -907908 9201 -907908 9294 -906909 9294 -906909 9201]...\r\n[ -997998 201 -997998 289 -996999 289 -996999 201]...\r\n[ -911912 8801 -911912 8908 -910913 8908 -910913 8801]...\r\n[ -972973 2701 -972973 2826 -971974 2826 -971974 2701]...\r\n[ -952953 4701 -952953 4817 -951954 4817 -951954 4701]...\r\n[ -980981 1901 -980981 2010 -979982 2010 -979982 1901]...\r\n[ -932933 6701 -932933 6783 -931934 6783 -931934 6701]...\r\n[ -964965 3501 -964965 3609 -963966 3609 -963966 3501]...\r\n[ -978979 2101 -978979 2194 -977980 2194 -977980 2101]...\r\n[ -925926 7401 -925926 7505 -924927 7505 -924927 7401]...\r\n[ -973974 2601 -973974 2703 -972975 2703 -972975 2601]...\r\n[ -990991 901 -990991 1002 -989992 1002 -989992 901]...\r\n[ -966967 3301 -966967 3389 -965968 3389 -965968 3301]...\r\n[ -977978 2201 -977978 2297 -976979 2297 -976979 2201]...\r\n[ -945946 5401 -945946 5505 -944947 5505 -944947 5401]...\r\n[ -938939 6101 -938939 6229 -937940 6229 -937940 6101]...\r\n[ -909910 9001 -909910 9080 -908911 9080 -908911 9001]...\r\n[ -924925 7501 -924925 7629 -923926 7629 -923926 7501]...\r\n[ -900901 9901 -900901 10022 -899902 10022 -899902 9901]...\r\n[ -954955 4501 -954955 4605 -953956 4605 -953956 4501]...\r\n[ -926927 7301 -926927 7382 -925928 7382 -925928 7301]...\r\n[ -905906 9401 -905906 9507 -904907 9507 -904907 9401]...\r\n[ -981982 1801 -981982 1892 -980983 1892 -980983 1801]...\r\n[ -1000000 1 -1000000 102 -999001 102 -999001 1]...\r\n[ -930931 6901 -930931 7023 -929932 7023 -929932 6901]...\r\n[ -959960 4001 -959960 4123 -958961 4123 -958961 4001]...\r\n[ -917918 8201 -917918 8319 -916919 8319 -916919 8201]...\r\n[ -942943 5701 -942943 5794 -941944 5794 -941944 5701]...\r\n[ -941942 5801 -941942 5880 -940943 5880 -940943 5801]...\r\n[ -901902 9801 -901902 9922 -900903 9922 -900903 9801]...\r\n[ -995996 401 -995996 510 -994997 510 -994997 401]...\r\n[ -903904 9601 -903904 9683 -902905 9683 -902905 9601]...\r\n[ -914915 8501 -914915 8623 -913916 8623 -913916 8501]...\r\n[ -998999 101 -998999 192 -998000 192 -998000 101]...\r\n[ -921922 7801 -921922 7885 -920923 7885 -920923 7801]...\r\n[ -969970 3001 -969970 3116 -968971 3116 -968971 3001]...\r\n[ -912913 8701 -912913 8812 -911914 8812 -911914 8701]...\r\n[ -987988 1201 -987988 1328 -986989 1328 -986989 1201]...\r\n[ -902903 9701 -902903 9827 -901904 9827 -901904 9701]...\r\n[ -982983 1701 -982983 1815 -981984 1815 -981984 1701]...\r\n[ -920921 7901 -920921 8002 -919922 8002 -919922 7901]...\r\n[ -971972 2801 -971972 2891 -970973 2891 -970973 2801]...\r\n[ -979980 2001 -979980 2107 -978981 2107 -978981 2001]...\r\n[ -939940 6001 -939940 6085 -938941 6085 -938941 6001]...\r\n[ -906907 9301 -906907 9416 -905908 9416 -905908 9301]...\r\n[ -951952 4801 -951952 4889 -950953 4889 -950953 4801]...\r\n[ -946947 5301 -946947 5404 -945948 5404 -945948 5301]...\r\n[ -961962 3801 -961962 3905 -960963 3905 -960963 3801]...\r\n[ -916917 8301 -916917 8404 -915918 8404 -915918 8301]...\r\n[ -983984 1601 -983984 1680 -982985 1680 -982985 1601]...\r\n[ -937938 6201 -937938 6290 -936939 6290 -936939 6201]...\r\n[ -963964 3601 -963964 3693 -962965 3693 -962965 3601]...\r\n[ -922923 7701 -922923 7814 -921924 7814 -921924 7701]...\r\n[ -962963 3701 -962963 3816 -961964 3816 -961964 3701]...\r\n[ -931932 6801 -931932 6890 -930933 6890 -930933 6801]...\r\n[ -960961 3901 -960961 4021 -959962 4021 -959962 3901]...\r\n[ -984985 1501 -984985 1624 -983986 1624 -983986 1501]...\r\n[ -992993 701 -992993 810 -991994 810 -991994 701]...\r\n[ -986987 1301 -986987 1390 -985988 1390 -985988 1301]...\r\n[ -955956 4401 -955956 4504 -954957 4504 -954957 4401]...\r\n[ -919920 8001 -919920 8086 -918921 8086 -918921 8001]...\r\n[ -944945 5501 -944945 5613 -943946 5613 -943946 5501]...\r\n[ -943944 5601 -943944 5718 -942945 5718 -942945 5601]...\r\n[ -974975 2501 -974975 2590 -973976 2590 -973976 2501]...\r\n[ -913914 8601 -913914 8696 -912915 8696 -912915 8601]...\r\n[ -923924 7601 -923924 7692 -922925 7692 -922925 7601]...\r\n[ -985986 1401 -985986 1491 -984987 1491 -984987 1401]...\r\n[ -996997 301 -996997 387 -995998 387 -995998 301]...\r\n[ -934935 6501 -934935 6623 -933936 6623 -933936 6501]...\r\n[ -953954 4601 -953954 4720 -952955 4720 -952955 4601]...\r\n[ -933934 6601 -933934 6702 -932935 6702 -932935 6601]...\r\n[ -991992 801 -991992 893 -990993 893 -990993 801]...\r\n[ -910911 8901 -910911 9000 -909912 9000 -909912 8901]...\r\n[ -967968 3201 -967968 3298 -966969 3298 -966969 3201]...\r\n[ -908909 9101 -908909 9219 -907910 9219 -907910 9101]...\r\n[ -949950 5001 -949950 5113 -948951 5113 -948951 5001]...\r\n[ -993994 601 -993994 717 -992995 717 -992995 601]...\r\n[ -948949 5101 -948949 5199 -947950 5199 -947950 5101]...\r\n[ -950951 4901 -950951 5014 -949952 5014 -949952 4901]...\r\n[ -958959 4101 -958959 4218 -957960 4218 -957960 4101]...\r\n[ -928929 7101 -928929 7196 -927930 7196 -927930 7101]...\r\n[ -904905 9501 -904905 9604 -903906 9604 -903906 9501]...\r\n[ -976977 2301 -976977 2422 -975978 2422 -975978 2301]...\r\n[ -929930 7001 -929930 7122 -928931 7122 -928931 7001]...\r\n[ -994995 501 -994995 607 -993996 607 -993996 501]...\r\n[ -935936 6401 -935936 6515 -934937 6515 -934937 6401]...\r\n[ -936937 6301 -936937 6415 -935938 6415 -935938 6301]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-1536.76)\u003c.01)\r\ntoc\r\n\r\n\r\n%%\r\ntic\r\nw=120;%case 9 35.62\r\npolycell={[0 10 0 90 50 50 100 90 100 10]...\r\n [0 110 100 110 50 70]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-35.6174)\u003c.01)\r\ntoc\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":"2013-04-25T19:40:38.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-04-25T04:08:54.000Z","updated_at":"2013-04-25T19:40:38.000Z","published_at":"2013-04-25T19:40:38.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\u003eThis Challenge is to solve 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=\\\"http://contest.usc.edu/index.php/Spring13/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC Spring 2013 ACM Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e Problem E, Walking on Thin Ice.\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 Rooster is crossing to the other side of the frozen river. Minimize his distance traveled on thin ice given a river width (w) and polygons(polycell) that denote non-thin ice regions. Start anywhere on the x-axis(y=0) and finish by reaching y=w.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\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\u003ew=120\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\u003epolycell={[0 10 0 90 50 50 100 90 100 10] [0 110 100 110 50 70]};\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 35.6174\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 only USC competition solver(45 minutes):\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Spring13/Home?action=download\u0026amp;upname=thinice.zhengcao.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCao's C solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTheory:\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\u003eTraveling Salesman Optimum Route. (Matlab one line while)\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\u003eCreate Interconnect Matrix\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\u003eCalculate Route/Distances between Good-Ice using Polygon to Polygon distance function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePolygon to Polygon minimum distance uses minimum Point to Line Segment function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRelated Challenges:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/1446-minimum-distance-point-to-segment\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMinimum Distance Point to Segment\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/1452-minimum-distance-between-two-n-sided-polygons\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMinimum Distance between Polygons\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":1101,"title":"USC Fall 2012 ACM : Chemical Analysis","description":"This Challenge is to solve Question D, Chemical Analysis, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nGiven an array M of Element Spectral signatures(m elements by n Spectra) and a Sample spectra of width n, determine the minimum number of elements that could generate the Sample's spectra.\r\n\r\n\r\nInput: [ A, Sample ]\r\n\r\nOutput: min_elements; \r\n\r\nThe minimum number Components to create the Sample Spectra. If no combination exists then output 0.\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=analysis.in.txt USC data file\u003e\r\n\r\nInput: [1 1 0 0;0 1 1 1;0 1 1 0;0 1 0 1], [1 1 0 1]\r\n\r\nOutput: 2 as [1 1 0 0] and [0 1 0 1] can create [1 1 0 1]\r\n\r\n\r\n\r\nThe Winning C solution is in the Test Suite to assist - not likely.\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question D, Chemical Analysis, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGiven an array M of Element Spectral signatures(m elements by n Spectra) and a Sample spectra of width n, determine the minimum number of elements that could generate the Sample's spectra.\u003c/p\u003e\u003cp\u003eInput: [ A, Sample ]\u003c/p\u003e\u003cp\u003eOutput: min_elements;\u003c/p\u003e\u003cp\u003eThe minimum number Components to create the Sample Spectra. If no combination exists then output 0.\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=analysis.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInput: [1 1 0 0;0 1 1 1;0 1 1 0;0 1 0 1], [1 1 0 1]\u003c/p\u003e\u003cp\u003eOutput: 2 as [1 1 0 0] and [0 1 0 1] can create [1 1 0 1]\u003c/p\u003e\u003cp\u003eThe Winning C solution is in the Test Suite to assist - not likely.\u003c/p\u003e","function_template":"function min_elements=Chem_analysis(A,Sample) \r\n min_elements=0;\r\nend","test_suite":"%%\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=analysis.in.txt','analysis_in.txt')\r\ntoc\r\n%%\r\n fid=fopen('analysis_in.txt','r');\r\n min_elements_expected=[2 0 1 2 0 3 4];\r\n\r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty\r\n  n = fscanf(fid,'%i %i\\n',2)'; % cols / rows\r\n   \r\n  A=zeros(n)'; % Format is colmns, rows\r\n  for i=1:n(2)\r\n   strv = fgetl(fid);\r\n   A(i,:) = strv - '0';\r\n  end\r\n   strv=fgetl(fid);\r\n   Sample=strv - '0';\r\n    \r\n  min_elements=Chem_analysis(A,Sample);\r\n    \r\n  assert(isequal(min_elements,min_elements_expected(q)));\r\n end % for q\r\n \r\n fclose(fid);\r\n\r\n\r\n% The C Winning Solution\r\n% #include \u003ciostream\u003e\r\n% #include \u003cfstream\u003e\r\n% #include \u003cstring\u003e\r\n% using namespace std;\r\n% int testcases;\r\n% int n, m;\r\n% int now;\r\n% int best;\r\n% string goal;\r\n% string s[1000];\r\n% void search(int i, string status)\r\n% {\r\n% \tif (i == n)\r\n% \t{\r\n% \t\tif (status == goal)\r\n% \t\t{\r\n% \t\t if ((best \u003c 0) || (now \u003c best)) best = now;\r\n% \t\t}\r\n% \t\treturn;\r\n% \t}\r\n% \tsearch(i + 1, status);\r\n% \tstring tmp = status;\r\n% \tfor (int j = 0; j \u003c m; j ++)\r\n% \t{\r\n% \t\tif (s[i][j] == '1') tmp[j] = '1';\r\n% \t}\r\n% \tnow ++;\r\n% \tsearch(i + 1, tmp);\r\n% \tnow --;\r\n% }\r\n% int main()\r\n% {\r\n% \tifstream inf(\"analysis.in\");\r\n% \tinf \u003e\u003e testcases;\r\n% \tfor (int testcase = 1; testcase \u003c= testcases; testcase ++)\r\n% \t{\r\n% \t\tcout \u003c\u003c \"Data Set \" \u003c\u003c testcase \u003c\u003c \":\" \u003c\u003c endl;\r\n% \t\tinf \u003e\u003e m \u003e\u003e n;\r\n% \t\tfor (int i = 0; i \u003c n; i ++)\r\n% \t\t\tinf \u003e\u003e s[i];\r\n% \t\tinf \u003e\u003e goal;\r\n% \t\tbest = -1;\r\n% \t\tstring ini = \"\";\r\n% \t\tfor (int i = 0; i \u003c m; i ++)\r\n% \t\t\tini = ini + \"0\";\r\n% \t\tnow = 0;\r\n% \t\tsearch(0, ini);\r\n%  if (best \u003c 0) cout \u003c\u003c \"Impossible\" \u003c\u003c endl; else cout \u003c\u003c best \u003c\u003c endl;\r\n% \t\tcout \u003c\u003c endl;\r\n% \t}\r\n% \tinf.close();\r\n% \treturn 0;\r\n% }\r\n% \r\n%\r\n%\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-06T20:21:50.000Z","updated_at":"2012-12-06T20:32:33.000Z","published_at":"2012-12-06T20:32:33.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\u003eThis Challenge is to solve Question D, Chemical Analysis, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an array M of Element Spectral signatures(m elements by n Spectra) and a Sample spectra of width n, determine the minimum number of elements that could generate the Sample's spectra.\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\u003eInput: [ A, Sample ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: min_elements;\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 minimum number Components to create the Sample Spectra. If no combination exists then output 0.\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=analysis.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eInput: [1 1 0 0;0 1 1 1;0 1 1 0;0 1 0 1], [1 1 0 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: 2 as [1 1 0 0] and [0 1 0 1] can create [1 1 0 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Winning C solution is in the Test Suite to assist - not likely.\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":1102,"title":"USC Fall 2012 ACM : Find Largest Water Concentration","description":"This Challenge is to solve Question B, Water?, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nGiven a character array A of minerals(A:Z) and a vector, iswater, of Water bearing minerals(A:Z) and a minimum rectangular size to evaluate, determine the Region with the Maximum water density. Report the larger region if two have the same density. \r\n\r\nSpecifically, report the Total water symbols and the Area of the highest density region. \r\n\r\n\r\nInput: [ A, iswater, s ]\r\n\r\nOutput: [Total Water Symbols, Area of Rectangle]; \r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.in.txt USC data file\u003e\r\n\r\nExample:\r\n\r\nInput: A, iswater, s\r\n\r\n  Matrix A\r\n  ITTTTHHHHTTTT\r\n  IXYOXOOOOOOXI\r\n  IOOOXOOOOOXXJ\r\n  IYOOOOXOOOOOI\r\n  IXXOYOOYOOOOI\r\n  IAAAAAXAXAAAJ\r\n  \r\n  iswater vector\r\n  YX\r\n  \r\n  s is 3; This is the minimum allowed rectangle size\r\n  \r\n\r\nOutput: [8 16] as there are 8 \"water symbols\" in a 4x4=16 square TLC:(2,2)\r\n\r\n\r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.rongqiqiu.cpp.txt The Winning B solution\u003e is very large.\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question B, Water?, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGiven a character array A of minerals(A:Z) and a vector, iswater, of Water bearing minerals(A:Z) and a minimum rectangular size to evaluate, determine the Region with the Maximum water density. Report the larger region if two have the same density.\u003c/p\u003e\u003cp\u003eSpecifically, report the Total water symbols and the Area of the highest density region.\u003c/p\u003e\u003cp\u003eInput: [ A, iswater, s ]\u003c/p\u003e\u003cp\u003eOutput: [Total Water Symbols, Area of Rectangle];\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003eInput: A, iswater, s\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eMatrix A\r\nITTTTHHHHTTTT\r\nIXYOXOOOOOOXI\r\nIOOOXOOOOOXXJ\r\nIYOOOOXOOOOOI\r\nIXXOYOOYOOOOI\r\nIAAAAAXAXAAAJ\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eiswater vector\r\nYX\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003es is 3; This is the minimum allowed rectangle size\r\n\u003c/pre\u003e\u003cp\u003eOutput: [8 16] as there are 8 \"water symbols\" in a 4x4=16 square TLC:(2,2)\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.rongqiqiu.cpp.txt\"\u003eThe Winning B solution\u003c/a\u003e is very large.\u003c/p\u003e","function_template":"function [w,w_area]=Water_analysis(A,iswater,s) \r\n w=0;\r\n w_area=s^2;\r\n \r\nend","test_suite":"%%\r\n%http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.in.txt\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.in.txt','water_in.txt');\r\ntoc\r\n%%\r\n fid=fopen('water_in.txt','r');\r\n w_area_expect=[8 16;100 100;0 1;1 1;5 9;186 675;23 110; 480 2500;102 2500;61 400; ...\r\n     73 930;160 441; 678 800; 55 361; 53 195;216 1296;199 1110;81 576;232 552;12 30;9 25;15 25;25 143; ...\r\n     66 120;2500 2500;270 1680;264 900;292 1365;748 2401;244 609;315 1296;214 1188];\r\n \r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty\r\n  n = fscanf(fid,'%i %i %i\\n',3)'; % rows / cols / min rect\r\n  s=n(3);\r\n  n=n(1:2);\r\n \r\n  strv=fgetl(fid);\r\n  iswater=strv;\r\n  \r\n  A=zeros(n); % Format is rows, columns\r\n  for i=1:n(1)\r\n   strv = fgetl(fid);\r\n   A(i,:) = strv;\r\n  end\r\n  A=char(A);\r\n\r\n  [w,w_area]=Water_analysis(A,iswater,s);\r\n  \r\n  assert(isequal([w w_area],w_area_expect(q,:)));\r\n\r\n end\r\n \r\n fprintf('Processing Complete\\n\\n')\r\n fclose(fid);\r\ntoc\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-07T02:38:08.000Z","updated_at":"2025-11-21T09:56:08.000Z","published_at":"2012-12-07T04:04:40.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\u003eThis Challenge is to solve Question B, Water?, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a character array A of minerals(A:Z) and a vector, iswater, of Water bearing minerals(A:Z) and a minimum rectangular size to evaluate, determine the Region with the Maximum water density. Report the larger region if two have the same density.\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\u003eSpecifically, report the Total water symbols and the Area of the highest density region.\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\u003eInput: [ A, iswater, s ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: [Total Water Symbols, Area of Rectangle];\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput: A, iswater, s\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[Matrix A\\nITTTTHHHHTTTT\\nIXYOXOOOOOOXI\\nIOOOXOOOOOXXJ\\nIYOOOOXOOOOOI\\nIXXOYOOYOOOOI\\nIAAAAAXAXAAAJ\\n\\niswater vector\\nYX\\n\\ns is 3; This is the minimum allowed rectangle size]]\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\u003eOutput: [8 16] as there are 8 \\\"water symbols\\\" in a 4x4=16 square TLC:(2,2)\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.rongqiqiu.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Winning B solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is very large.\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":1109,"title":"USC Spring 2012 ACM: Armageddon","description":"This Challenge is to solve Question E, Armageddon, of the \u003chttp://contest.usc.edu/index.php/Spring12/Home USC ACM Spring 2012 Contest\u003e.\r\n\r\nAn asteroid has been detected that will traverse the center of the earth if it is not deflected. The Splitter missile will bisect the asteroid with an included angle (\u003e0, \u003c180 degrees), based on its composition. The asteroids distance(to center of earth), velocity, and split angle will be provided. The Splitter missile velocity is also provided. Launch occurs from the earth surface nearest the asteroid. Miscellaneous details: Earth Radius 6378.1 km, velocities in km/sec, distance in km\r\n, and angle in degrees.\r\n\r\nReturn the Maximum Time Prior to Launch, nothing hitting the earth, to two decimal places. \r\n\r\n\r\n*Input: [ Asteroid Distance, Angle of Split, Asteroid Velocity, Missile Velocity ]*\r\n\r\n*Output: [Maximum Time Prior to Launch]*; if too late return -1;\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Spring12/Home?action=download\u0026upname=armageddon.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: 63781.0 20.9514 6378.1 6378.1*\r\n\r\n*Output: 0.00* as immediate Launch is required  \r\n\r\nInput 47835.75,15,6000,5000 returns -1.\r\n\r\n\r\n\u003chttp://contest.usc.edu/index.php/Spring12/Home?action=download\u0026upname=numerology_darryl.cpp.txt The Judges' E solution\u003e.\r\n\r\nGeometry Hint: Draw a circle and a line from the center of  approximately 2 radius. Take a ruler pivoting from the end of the line and rotate the ruler until it touches the circle.\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question E, Armageddon, of the \u003ca href=\"http://contest.usc.edu/index.php/Spring12/Home\"\u003eUSC ACM Spring 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eAn asteroid has been detected that will traverse the center of the earth if it is not deflected. The Splitter missile will bisect the asteroid with an included angle (\u003e0, \u0026lt;180 degrees), based on its composition. The asteroids distance(to center of earth), velocity, and split angle will be provided. The Splitter missile velocity is also provided. Launch occurs from the earth surface nearest the asteroid. Miscellaneous details: Earth Radius 6378.1 km, velocities in km/sec, distance in km\r\n, and angle in degrees.\u003c/p\u003e\u003cp\u003eReturn the Maximum Time Prior to Launch, nothing hitting the earth, to two decimal places.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [ Asteroid Distance, Angle of Split, Asteroid Velocity, Missile Velocity ]\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [Maximum Time Prior to Launch]\u003c/b\u003e; if too late return -1;\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=armageddon.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: 63781.0 20.9514 6378.1 6378.1\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: 0.00\u003c/b\u003e as immediate Launch is required\u003c/p\u003e\u003cp\u003eInput 47835.75,15,6000,5000 returns -1.\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=numerology_darryl.cpp.txt\"\u003eThe Judges' E solution\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGeometry Hint: Draw a circle and a line from the center of  approximately 2 radius. Take a ruler pivoting from the end of the line and rotate the ruler until it touches the circle.\u003c/p\u003e","function_template":"function [t_launch]=Armageddon(xa,angle,va,vm)\r\n  t_launch=-1;\r\nend","test_suite":"%%\r\n% Armegeddon\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026upname=armageddon.in.txt','armageddon.in.txt')\r\ntoc\r\n%%\r\n fid=fopen('armageddon.in.txt','r');\r\n \r\n t_expect=[0.00 -1 20.55 -1 -1 28.38 -1 11.03 2.62 4.22 13.15 9.94 61.33 13.56 -1];\r\n \r\n  \r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty %qty\r\n  n = fscanf(fid,'%f %f %f %f \\n',4)'; % dist, angle, vel A, vel Missile\r\n  xa=n(1);\r\n  angle=n(2);\r\n  va=n(3);\r\n  vm=n(4);\r\n  \r\n  [t]=Armageddon(xa,angle,va,vm) ;\r\n  \r\n  \r\n  assert(isequal(t,t_expect(q)))\r\n  \r\n   \r\n  end\r\n   \r\n fclose(fid);\r\ntoc","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":"2012-12-09T06:02:07.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-08T21:43:00.000Z","updated_at":"2012-12-09T15:08:14.000Z","published_at":"2012-12-08T22:02:35.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\u003eThis Challenge is to solve Question E, Armageddon, of 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=\\\"http://contest.usc.edu/index.php/Spring12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Spring 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAn asteroid has been detected that will traverse the center of the earth if it is not deflected. The Splitter missile will bisect the asteroid with an included angle (\u0026gt;0, \u0026lt;180 degrees), based on its composition. The asteroids distance(to center of earth), velocity, and split angle will be provided. The Splitter missile velocity is also provided. Launch occurs from the earth surface nearest the asteroid. Miscellaneous details: Earth Radius 6378.1 km, velocities in km/sec, distance in km , and angle in degrees.\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\u003eReturn the Maximum Time Prior to Launch, nothing hitting the earth, to two 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [ Asteroid Distance, Angle of Split, Asteroid Velocity, Missile Velocity ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [Maximum Time Prior to Launch]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; if too late return -1;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=armageddon.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: 63781.0 20.9514 6378.1 6378.1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: 0.00\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as immediate Launch is required\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\u003eInput 47835.75,15,6000,5000 returns -1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=numerology_darryl.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Judges' E solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGeometry Hint: Draw a circle and a line from the center of approximately 2 radius. Take a ruler pivoting from the end of the line and rotate the ruler until it touches the circle.\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":1115,"title":"USC Fall 2012 ACM: Driving the Rover","description":"This Challenge is to solve Question E, Driving the Rover, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nThe Rover is sent a Series of commands. Your task is to emulate the Rover response to the sequence and determine its \"final position\", [x,y]. The \"final position\" is the Rover location 1 second after the final command.\r\n\r\n  Initial conditions are Rover Stopped and Facing +Y.\r\n  Commands are processed at 1 second intervals\r\n  \r\n  Commands and their attributes:\r\n  FORWARD: Starts rolling forward at 1 cm/s\r\n  BACKWARDS: Roll backwards at 1 cm/s\r\n  FASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\n  SLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\n  STOP: Halts rover movement\r\n  RIGHT: Turn rover 90 degrees to the right\r\n  LEFT: Turn the rover 90 degrees to the left\r\n  NOOP: No change in anything \r\n\r\n\r\n  Commands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\r\n  Commands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\r\n\r\n*Input: [Cell array of Rover Commands]*\r\n\r\n*Output: [x, y ]*; Final Position 1 second after last command;\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=driving.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: {'FORWARD' 'RIGHT' 'STOP' 'RIGHT' 'FORWARD' 'FASTER'}*\r\n\r\n*Output: [3 2]* as the first RIGHT is ignored \r\n \r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=driving.bozhang.cpp.txt A Contest Drive solution\u003e.  Time to Solve: 9 minutes. Start.\r\n\r\nThis is predecessor to the Martian Pits Challenge.\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question E, Driving the Rover, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eThe Rover is sent a Series of commands. Your task is to emulate the Rover response to the sequence and determine its \"final position\", [x,y]. The \"final position\" is the Rover location 1 second after the final command.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInitial conditions are Rover Stopped and Facing +Y.\r\nCommands are processed at 1 second intervals\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands and their attributes:\r\nFORWARD: Starts rolling forward at 1 cm/s\r\nBACKWARDS: Roll backwards at 1 cm/s\r\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\nSTOP: Halts rover movement\r\nRIGHT: Turn rover 90 degrees to the right\r\nLEFT: Turn the rover 90 degrees to the left\r\nNOOP: No change in anything \r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput: [Cell array of Rover Commands]\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [x, y ]\u003c/b\u003e; Final Position 1 second after last command;\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: {'FORWARD' 'RIGHT' 'STOP' 'RIGHT' 'FORWARD' 'FASTER'}\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [3 2]\u003c/b\u003e as the first RIGHT is ignored\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.bozhang.cpp.txt\"\u003eA Contest Drive solution\u003c/a\u003e.  Time to Solve: 9 minutes. Start.\u003c/p\u003e\u003cp\u003eThis is predecessor to the Martian Pits Challenge.\u003c/p\u003e","function_template":"function xy=Drive(m)\r\n  xy=[0,0];\r\nend","test_suite":"%%\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=driving.in.txt','driving.in.txt');\r\ntoc\r\n%%\r\n fid=fopen('driving.in.txt','r');\r\n xy_expect=[3 2;2 29;107 23;-79 -72];\r\n \r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty %qty\r\n  n = fscanf(fid,'%f\\n',1); % commands\r\n  m=cell(n,1);\r\n  for i=1:n\r\n   m{i}=fgetl(fid);\r\n  end\r\n \r\n   [xy]=Drive(m) ;\r\n   assert(isequal(xy,xy_expect(q,:)))\r\n%   fprintf('Q %i  x %i  y %i  Pass %i\\n',q,xy,tf)\r\n   \r\n  \r\n end % q\r\n \r\n fclose(fid);\r\ntoc","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-12T03:32:42.000Z","updated_at":"2012-12-12T04:06:15.000Z","published_at":"2012-12-12T04:06:15.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\u003eThis Challenge is to solve Question E, Driving the Rover, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Rover is sent a Series of commands. Your task is to emulate the Rover response to the sequence and determine its \\\"final position\\\", [x,y]. The \\\"final position\\\" is the Rover location 1 second after the final command.\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[Initial conditions are Rover Stopped and Facing +Y.\\nCommands are processed at 1 second intervals\\n\\nCommands and their attributes:\\nFORWARD: Starts rolling forward at 1 cm/s\\nBACKWARDS: Roll backwards at 1 cm/s\\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \\\"Stopped\\\"\\nSTOP: Halts rover movement\\nRIGHT: Turn rover 90 degrees to the right\\nLEFT: Turn the rover 90 degrees to the left\\nNOOP: No change in anything \\n\\nCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\\n\\nCommands FASTER and SLOWER only take effect if the rover is moving forward.]]\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [Cell array of Rover Commands]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [x, y ]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; Final Position 1 second after last command;\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: {'FORWARD' 'RIGHT' 'STOP' 'RIGHT' 'FORWARD' 'FASTER'}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [3 2]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as the first RIGHT is ignored\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.bozhang.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eA Contest Drive solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Time to Solve: 9 minutes. Start.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is predecessor to the Martian Pits Challenge.\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":1110,"title":"USC Fall 2012 ACM: Martian Pranks","description":"This Challenge is to solve Question C, Martian Pranks, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nRocks are moving between Rover pictures. This proves Life on Mars, but how Fast is that Life? \r\n\r\nAll Rocks are bounded by a square with opposite corners (0,0) and (1,1). The camera only sees this 1x1 area. One Martian per Rock. Martians travel the minimum distance from the 1x1 edge to the initial rock position and from the final rock position to the edge to hide at velocity V. While moving a rock Marty's velocity reduces to V/2. An unmoved rock allows Marty to stay on the sideline. Note, the camera software does not track specific rocks, so an unmoved rock in Pict1 may be item 1 and this same rock may be item 4 in the second picture. Multiple rocks may occupy the same location in a picture.  \r\n\r\nReturn the Minimum Martian Speed to transition from the initial Rock set to the Final rock set. \r\n\r\n\r\n*Input: [Rock_locations_Pict1_Pict2,Time between pictures ]*\r\n\r\n*Output: [Minimum Martian Speed]*; to 2 decimal places;\r\n\r\n*Scoring: Cumulative Time ( msec )*\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pranks.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: [0.3 0.6;0.4 0.5;0.5 0.5;0.95 0.2;0.6 0.5;0.9 0.4;0.5 0.5; 0.3 0.6], 3.0*\r\n\r\nEssentially, 4 rocks in two pictures with a time between pictures of 3 seconds\r\n\r\n*Output: 0.37* is quite obvious, not in the least \r\n \r\nThis answer comes by moving [I1 F4; I2 F3; I3 F1; I4 F2] with rows two and three  being of equal maximum effective distance of 1.1. My \"effective distance\" for I2 F3 is .4 + (.1)*2 + .5, where .1 is hypot(I2,F3) and multiply by 2 for speed reduction. This 1.1/3 rounds to 0.37.\r\n\r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pranks.zhencao.cpp.txt The Winner's Pranks solution\u003e.  This solution is much tighter than my first method thus I am scoring by time.  Hopefully someone can champion Matlab and produce a succinct and worthy solution. The winner solved this in 22 minutes and second place took a leisurely 65 minutes. Time Started when the page was opened.\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question C, Martian Pranks, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eRocks are moving between Rover pictures. This proves Life on Mars, but how Fast is that Life?\u003c/p\u003e\u003cp\u003eAll Rocks are bounded by a square with opposite corners (0,0) and (1,1). The camera only sees this 1x1 area. One Martian per Rock. Martians travel the minimum distance from the 1x1 edge to the initial rock position and from the final rock position to the edge to hide at velocity V. While moving a rock Marty's velocity reduces to V/2. An unmoved rock allows Marty to stay on the sideline. Note, the camera software does not track specific rocks, so an unmoved rock in Pict1 may be item 1 and this same rock may be item 4 in the second picture. Multiple rocks may occupy the same location in a picture.\u003c/p\u003e\u003cp\u003eReturn the Minimum Martian Speed to transition from the initial Rock set to the Final rock set.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [Rock_locations_Pict1_Pict2,Time between pictures ]\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [Minimum Martian Speed]\u003c/b\u003e; to 2 decimal places;\u003c/p\u003e\u003cp\u003e\u003cb\u003eScoring: Cumulative Time ( msec )\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [0.3 0.6;0.4 0.5;0.5 0.5;0.95 0.2;0.6 0.5;0.9 0.4;0.5 0.5; 0.3 0.6], 3.0\u003c/b\u003e\u003c/p\u003e\u003cp\u003eEssentially, 4 rocks in two pictures with a time between pictures of 3 seconds\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: 0.37\u003c/b\u003e is quite obvious, not in the least\u003c/p\u003e\u003cp\u003eThis answer comes by moving [I1 F4; I2 F3; I3 F1; I4 F2] with rows two and three  being of equal maximum effective distance of 1.1. My \"effective distance\" for I2 F3 is .4 + (.1)*2 + .5, where .1 is hypot(I2,F3) and multiply by 2 for speed reduction. This 1.1/3 rounds to 0.37.\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.zhencao.cpp.txt\"\u003eThe Winner's Pranks solution\u003c/a\u003e.  This solution is much tighter than my first method thus I am scoring by time.  Hopefully someone can champion Matlab and produce a succinct and worthy solution. The winner solved this in 22 minutes and second place took a leisurely 65 minutes. Time Started when the page was opened.\u003c/p\u003e","function_template":"function [v]=Pranks(R,t)\r\n  v=0;\r\nend","test_suite":"feval(@assignin,'caller','score',4000);\r\n%%\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pranks.in.txt','pranks.in.txt')\r\ntoc\r\n%%\r\n fid=fopen('pranks.in.txt','r');\r\n v_expect=[.37 .26 1.11 .02 .89 .79 .01 .17 .37 1.05 .28 .04 .02 .09 .14 .49 .71 .06 .01];\r\n \r\n qty=fscanf(fid,'%i',1);\r\n\r\n t1=0;\r\n for q=1:qty %qty\r\n  n = fscanf(fid,'%f %f \\n',2)'; % num_rocks, time\r\n  t=n(2);\r\n  \r\n  A=zeros(2*n(1),2); % Format is rows, columns\r\n  for i=1:2*n(1)\r\n   r = fscanf(fid,'%f %f \\n',2)';\r\n   A(i,:) = r;\r\n  end\r\n \r\n \r\n  tic\r\n  ta=clock;\r\n   [v]=Pranks(A,t) ;\r\n  t1=t1+etime(clock,ta)*1000; % Time in msec\r\n   \r\nfprintf('%2i  vel %.2f  Sum Time %.0f \\n',q,v,t1)\r\n  \r\n  assert(isequal(v,v_expect(q)));\r\n   \r\n end\r\n \r\n fprintf('Processing Complete\\n')\r\n fclose(fid);\r\n\r\n\r\nt2=min(4000,t1);\r\nfprintf('Actual Time = %.0f msec\\n',t1)\r\n\r\nfeval(@assignin,'caller','score',floor(t2));","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":3097,"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":"2012-12-10T00:08:26.000Z","updated_at":"2012-12-10T01:48:14.000Z","published_at":"2012-12-10T01:48:14.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\u003eThis Challenge is to solve Question C, Martian Pranks, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRocks are moving between Rover pictures. This proves Life on Mars, but how Fast is that Life?\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\u003eAll Rocks are bounded by a square with opposite corners (0,0) and (1,1). The camera only sees this 1x1 area. One Martian per Rock. Martians travel the minimum distance from the 1x1 edge to the initial rock position and from the final rock position to the edge to hide at velocity V. While moving a rock Marty's velocity reduces to V/2. An unmoved rock allows Marty to stay on the sideline. Note, the camera software does not track specific rocks, so an unmoved rock in Pict1 may be item 1 and this same rock may be item 4 in the second picture. Multiple rocks may occupy the same location in a picture.\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\u003eReturn the Minimum Martian Speed to transition from the initial Rock set to the Final rock set.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [Rock_locations_Pict1_Pict2,Time between pictures ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [Minimum Martian Speed]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; to 2 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eScoring: Cumulative Time ( msec )\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [0.3 0.6;0.4 0.5;0.5 0.5;0.95 0.2;0.6 0.5;0.9 0.4;0.5 0.5; 0.3 0.6], 3.0\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\u003eEssentially, 4 rocks in two pictures with a time between pictures of 3 seconds\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: 0.37\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is quite obvious, not in the least\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis answer comes by moving [I1 F4; I2 F3; I3 F1; I4 F2] with rows two and three being of equal maximum effective distance of 1.1. My \\\"effective distance\\\" for I2 F3 is .4 + (.1)*2 + .5, where .1 is hypot(I2,F3) and multiply by 2 for speed reduction. This 1.1/3 rounds to 0.37.\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.zhencao.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Winner's Pranks solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. This solution is much tighter than my first method thus I am scoring by time. Hopefully someone can champion Matlab and produce a succinct and worthy solution. The winner solved this in 22 minutes and second place took a leisurely 65 minutes. Time Started when the page was opened.\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":1122,"title":"USC Fall 2012 ACM: Rover Maze","description":"This Challenge is to solve Question F, Martian Pits, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nThe task is to determine the minimum time for the Rover to drive from its current position to a Goal location. The Rover must STOP on the Goal location. Commands are processed at 1 Cmd per sec. Rover must stay on array.\r\n\r\nThis is an intriguing Maze problem that incorporates turn penalties, variable speed forward, and a fixed reverse speed.\r\n\r\n  Initial conditions are Rover Stopped and Facing +Y.\r\n  Commands are processed at 1 second intervals\r\n  \r\n  Commands and their attributes:\r\n  FORWARD: Starts rolling forward at 1 cm/s\r\n  BACKWARDS: Roll backwards at 1 cm/s\r\n  FASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\n  SLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\n  STOP: Halts rover movement\r\n  RIGHT: Turn rover 90 degrees to the right\r\n  LEFT: Turn the rover 90 degrees to the left\r\n  NOOP: No change in anything \r\n\r\n\r\n  Commands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\r\n  Commands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\r\n\r\n*Input: [Char array]* \".\" is Flat ground, \"P\" Pit, \"R\" Rover start location, \"D\" is Destination.  Matrix max dim 50, min 1. \r\n\r\n*Output: [T]*; Drive Time to destination; -1 if not possible\r\n\r\n*Scoring: Time (msec)*\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pits.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: [A]*\r\n\r\n  ...................D\r\n  .P......P.P.........\r\n  .P...PPPP.P.........\r\n  .P...P....P.........\r\n  .P...P.PPPP.........\r\n  .P.PPP.P............\r\n  .P.P...P............\r\n  .PPP.PPPPPPPPPPPPPPP\r\n  ....R...............\r\n  PPPPPPPPPPPPPPPPPPPP\r\n\r\n*Output: [19]* as the best path is L, Fwd, Faster, Slower, Stop to (9,1). The cmds to reach (1,1) are R, Fwd, Faster, Faster, Slower, Stop. Cmds to optimally reach (1,20) are R, Fwd, Faster, Faster, Faster, Faster, Slower, Stop. \r\n\r\nOnce again my code is large thus the contest will be scored based on Processing Time.\r\n\r\n*Hints:* One Speed-Up method is to do an initial Start/Finish connectivity check.\r\n \r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pits.yucheng.cpp.txt Martian Pits C solution\u003e.  Time to Solve: 40 minutes. Only three solved this puzzle during the contest. Start.","description_html":"\u003cp\u003eThis Challenge is to solve Question F, Martian Pits, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eThe task is to determine the minimum time for the Rover to drive from its current position to a Goal location. The Rover must STOP on the Goal location. Commands are processed at 1 Cmd per sec. Rover must stay on array.\u003c/p\u003e\u003cp\u003eThis is an intriguing Maze problem that incorporates turn penalties, variable speed forward, and a fixed reverse speed.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInitial conditions are Rover Stopped and Facing +Y.\r\nCommands are processed at 1 second intervals\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands and their attributes:\r\nFORWARD: Starts rolling forward at 1 cm/s\r\nBACKWARDS: Roll backwards at 1 cm/s\r\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\nSTOP: Halts rover movement\r\nRIGHT: Turn rover 90 degrees to the right\r\nLEFT: Turn the rover 90 degrees to the left\r\nNOOP: No change in anything \r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput: [Char array]\u003c/b\u003e \".\" is Flat ground, \"P\" Pit, \"R\" Rover start location, \"D\" is Destination.  Matrix max dim 50, min 1.\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [T]\u003c/b\u003e; Drive Time to destination; -1 if not possible\u003c/p\u003e\u003cp\u003e\u003cb\u003eScoring: Time (msec)\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [A]\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e...................D\r\n.P......P.P.........\r\n.P...PPPP.P.........\r\n.P...P....P.........\r\n.P...P.PPPP.........\r\n.P.PPP.P............\r\n.P.P...P............\r\n.PPP.PPPPPPPPPPPPPPP\r\n....R...............\r\nPPPPPPPPPPPPPPPPPPPP\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eOutput: [19]\u003c/b\u003e as the best path is L, Fwd, Faster, Slower, Stop to (9,1). The cmds to reach (1,1) are R, Fwd, Faster, Faster, Slower, Stop. Cmds to optimally reach (1,20) are R, Fwd, Faster, Faster, Faster, Faster, Slower, Stop.\u003c/p\u003e\u003cp\u003eOnce again my code is large thus the contest will be scored based on Processing Time.\u003c/p\u003e\u003cp\u003e\u003cb\u003eHints:\u003c/b\u003e One Speed-Up method is to do an initial Start/Finish connectivity check.\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.yucheng.cpp.txt\"\u003eMartian Pits C solution\u003c/a\u003e.  Time to Solve: 40 minutes. Only three solved this puzzle during the contest. Start.\u003c/p\u003e","function_template":"function t=Pits(A)\r\n  t=-1;\r\n\r\nend","test_suite":"feval(@assignin,'caller','score',1000);\r\n%%\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pits.in.txt','pits.in.txt');\r\n%%\r\n fid=fopen('pits.in.txt','r');\r\n t_expect=[19 2 2 3 -1 7 14 23 401 200 42 -1 27 -1];\r\n \r\n t1=0;\r\n qty=fscanf(fid,'%i',1);\r\nfor q=1:qty %qty\r\n  n = fscanf(fid,'%f %f\\n',2)'; % array size\r\n  A=zeros(n);\r\n  for i=1:n(1)\r\n   strv=fgetl(fid);\r\n   %A(i,:)=strv-'.';\r\n   A(i,:)=strv;\r\n  end\r\n\r\n  ta=clock;\r\n   [t]=Pits(char(A)) ;\r\n  t1=t1+etime(clock,ta)*1000; % Time in msec\r\n   \r\n  fprintf('%2i  Cmds %3.0f  Sum Time %.0f \\n',q,t,t1)\r\n\r\n  %isequal(t,t_expect(q))\r\n\r\n  assert(isequal(t,t_expect(q)));\r\n\r\nend % q\r\n\r\nt2=min(1000,t1);\r\nfprintf('Actual Time = %.1f msec\\n',t1)\r\nfeval(@assignin,'caller','score',floor(t2));","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"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":"2012-12-14T01:14:38.000Z","updated_at":"2012-12-14T02:24:14.000Z","published_at":"2012-12-14T02:24:14.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\u003eThis Challenge is to solve Question F, Martian Pits, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe task is to determine the minimum time for the Rover to drive from its current position to a Goal location. The Rover must STOP on the Goal location. Commands are processed at 1 Cmd per sec. Rover must stay on array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is an intriguing Maze problem that incorporates turn penalties, variable speed forward, and a fixed reverse speed.\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[Initial conditions are Rover Stopped and Facing +Y.\\nCommands are processed at 1 second intervals\\n\\nCommands and their attributes:\\nFORWARD: Starts rolling forward at 1 cm/s\\nBACKWARDS: Roll backwards at 1 cm/s\\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \\\"Stopped\\\"\\nSTOP: Halts rover movement\\nRIGHT: Turn rover 90 degrees to the right\\nLEFT: Turn the rover 90 degrees to the left\\nNOOP: No change in anything \\n\\nCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\\n\\nCommands FASTER and SLOWER only take effect if the rover is moving forward.]]\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [Char array]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \\\".\\\" is Flat ground, \\\"P\\\" Pit, \\\"R\\\" Rover start location, \\\"D\\\" is Destination. Matrix max dim 50, min 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [T]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; Drive Time to destination; -1 if not possible\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eScoring: Time (msec)\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [A]\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[...................D\\n.P......P.P.........\\n.P...PPPP.P.........\\n.P...P....P.........\\n.P...P.PPPP.........\\n.P.PPP.P............\\n.P.P...P............\\n.PPP.PPPPPPPPPPPPPPP\\n....R...............\\nPPPPPPPPPPPPPPPPPPPP]]\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [19]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as the best path is L, Fwd, Faster, Slower, Stop to (9,1). The cmds to reach (1,1) are R, Fwd, Faster, Faster, Slower, Stop. Cmds to optimally reach (1,20) are R, Fwd, Faster, Faster, Faster, Faster, Slower, Stop.\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\u003eOnce again my code is large thus the contest will be scored based on Processing Time.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHints:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e One Speed-Up method is to do an initial Start/Finish connectivity check.\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.yucheng.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMartian Pits C solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Time to Solve: 40 minutes. Only three solved this puzzle during the contest. Start.\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":1098,"title":"USC Fall 2012 ACM : Code Word Minimum Flipped Bits","description":"This Challenge is to solve Question A of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nGiven an array M of Valid binary codewords(m codewords of width n) and a Received Corrupted(?) codeword of width n, determine the minimum number of flipped bits in the Received codeword to generate a valid codeword.\r\n\r\n\r\nInput: [ M, v ]\r\n\r\nOutput: e, minimum number of error(flipped) bits\r\n.\r\n\r\nFrom full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=codes.in.txt USC data file\u003e\r\n\r\nInput: [0 0 0; 1 1 1; 1 1 0], [0 1 0]\r\n\r\nOutput: 1 as [0 1 0] can convert to [0 0 0] or [1 1 0] with a single flip\r\n\r\nMatlab one-liner?\r\n\r\nThe Winning C solution - not much help:\r\n\r\n  #include \u003ciostream\u003e\r\n  #include \u003cstdio.h\u003e\r\n  #include \u003cstring\u003e\r\n  using namespace std;\r\n  int main () {\r\n  \tfreopen(\"codes.in\", \"r\", stdin);\r\n  \tint K,n,b;\r\n  \tcin \u003e\u003e K;\r\n  \tfor (int i = 1; i \u003c K + 1; ++i) {\r\n  \t\tcin \u003e\u003e n \u003e\u003e b;\r\n  \t\tstring m[1000], r;\r\n  \t\tfor (int j = 0; j \u003c n; ++j)\r\n  \t\t\tcin \u003e\u003e m[j];\r\n  \t\tcin \u003e\u003e r;\r\n% Process Start\t\t\r\n  \t\tint f = b;\r\n  \t\tfor (int j = 0; j \u003c n; ++j) {\r\n  \t\t\tint d = b;\r\n  \t\t\tfor (int k = 0; k \u003c b; ++k) {\r\n  \t\t\t\tif (m[j][k] == r[k])\r\n  \t\t\t\t\t--d;\r\n  \t\t\t}\r\n  \t\t\tf = ((f \u003c= d) ? f : d);\r\n  \t\t}\r\n % Process End \r\n  \t\tprintf(\"Data Set %d:\\n\", i);\r\n  \t\tprintf(\"%d\\n\\n\", f);\r\n  \t}\r\n  \treturn 0;\r\n  }\r\n  ","description_html":"\u003cp\u003eThis Challenge is to solve Question A of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGiven an array M of Valid binary codewords(m codewords of width n) and a Received Corrupted(?) codeword of width n, determine the minimum number of flipped bits in the Received codeword to generate a valid codeword.\u003c/p\u003e\u003cp\u003eInput: [ M, v ]\u003c/p\u003e\u003cp\u003eOutput: e, minimum number of error(flipped) bits\r\n.\u003c/p\u003e\u003cp\u003eFrom full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=codes.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInput: [0 0 0; 1 1 1; 1 1 0], [0 1 0]\u003c/p\u003e\u003cp\u003eOutput: 1 as [0 1 0] can convert to [0 0 0] or [1 1 0] with a single flip\u003c/p\u003e\u003cp\u003eMatlab one-liner?\u003c/p\u003e\u003cp\u003eThe Winning C solution - not much help:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e#include \u0026lt;iostream\u003e\r\n#include \u0026lt;stdio.h\u003e\r\n#include \u0026lt;string\u003e\r\nusing namespace std;\r\nint main () {\r\n\tfreopen(\"codes.in\", \"r\", stdin);\r\n\tint K,n,b;\r\n\tcin \u003e\u003e K;\r\n\tfor (int i = 1; i \u0026lt; K + 1; ++i) {\r\n\t\tcin \u003e\u003e n \u003e\u003e b;\r\n\t\tstring m[1000], r;\r\n\t\tfor (int j = 0; j \u0026lt; n; ++j)\r\n\t\t\tcin \u003e\u003e m[j];\r\n\t\tcin \u003e\u003e r;\r\n% Process Start\t\t\r\n\t\tint f = b;\r\n\t\tfor (int j = 0; j \u0026lt; n; ++j) {\r\n\t\t\tint d = b;\r\n\t\t\tfor (int k = 0; k \u0026lt; b; ++k) {\r\n\t\t\t\tif (m[j][k] == r[k])\r\n\t\t\t\t\t--d;\r\n\t\t\t}\r\n\t\t\tf = ((f \u0026lt;= d) ? f : d);\r\n\t\t}\r\n% Process End \r\n\t\tprintf(\"Data Set %d:\\n\", i);\r\n\t\tprintf(\"%d\\n\\n\", f);\r\n\t}\r\n\treturn 0;\r\n}\r\n\u003c/pre\u003e","function_template":"function f = USC_No_1(M,v)\r\n  f=0;\r\nend","test_suite":"%%\r\ntic\r\nurlfn='http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=codes.in.txt';\r\nurlwrite(urlfn,'codesin_A.txt'); % Load file from USC\r\ntoc\r\n%%\r\n flip_correct=[1 0 0 54 1 29 37 32 33 32 39 8 0 0 36 36 35];\r\n\r\n fid=fopen('codesin_A.txt','r');\r\n\r\n qty=fscanf(fid,'%i',1);\r\n for ptr=1:qty\r\n  nr=fscanf(fid,'%i',1);\r\n  nc=fscanf(fid,'%i',1);\r\n \r\n  A=zeros(nr,nc);\r\n  for i=1:nr\r\n   strv=fscanf(fid,'%s',1); % Reads a line of text\r\n   A(i,:)=strv-'0'; % vectorize the string\r\n  end\r\n \r\n  strv=fscanf(fid,'%s',1);\r\n  v=strv-'0';\r\n\r\n  USC_flips = USC_No_1(A,v);\r\n\r\n  assert(isequal(USC_flips,flip_correct(ptr)))\r\n \r\n end\r\n fclose(fid);\r\n \r\ntoc\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-06T02:14:30.000Z","updated_at":"2024-11-05T12:53:23.000Z","published_at":"2012-12-06T02:40:27.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\u003eThis Challenge is to solve Question A of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an array M of Valid binary codewords(m codewords of width n) and a Received Corrupted(?) codeword of width n, determine the minimum number of flipped bits in the Received codeword to generate a valid codeword.\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\u003eInput: [ M, v ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: e, minimum number of error(flipped) bits .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFrom full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=codes.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eInput: [0 0 0; 1 1 1; 1 1 0], [0 1 0]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: 1 as [0 1 0] can convert to [0 0 0] or [1 1 0] with a single flip\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\u003eMatlab one-liner?\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 Winning C solution - not much help:\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[#include \u003ciostream\u003e\\n#include \u003cstdio.h\u003e\\n#include \u003cstring\u003e\\nusing namespace std;\\nint main () {\\n  freopen(\\\"codes.in\\\", \\\"r\\\", stdin);\\n  int K,n,b;\\n  cin \u003e\u003e K;\\n  for (int i = 1; i \u003c K + 1; ++i) {\\n    cin \u003e\u003e n \u003e\u003e b;\\n    string m[1000], r;\\n    for (int j = 0; j \u003c n; ++j)\\n      cin \u003e\u003e m[j];\\n    cin \u003e\u003e r;\\n% Process Start    \\n    int f = b;\\n    for (int j = 0; j \u003c n; ++j) {\\n      int d = b;\\n      for (int k = 0; k \u003c b; ++k) {\\n        if (m[j][k] == r[k])\\n          --d;\\n      }\\n      f = ((f \u003c= d) ? f : d);\\n    }\\n% Process End \\n    printf(\\\"Data Set %d:\\\\n\\\", i);\\n    printf(\\\"%d\\\\n\\\\n\\\", f);\\n  }\\n  return 0;\\n}]]\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":1457,"title":"USC Spring 2013 ACM: Walking on Thin Ice","description":"This Challenge is to solve the \u003chttp://contest.usc.edu/index.php/Spring13/Home USC Spring 2013 ACM Contest\u003e Problem E, Walking on Thin Ice.\r\n\r\nThe Rooster is crossing to the other side of the frozen river. Minimize his distance traveled on thin ice given a river width (w) and polygons(polycell) that denote non-thin ice regions. Start anywhere on the x-axis(y=0) and finish by reaching y=w.\r\n\r\n*Input:* \r\n\r\nw=120 \r\n\r\npolycell={[0 10 0 90 50 50 100 90 100 10] [0 110 100 110 50 70]};\r\n\r\n*Output:* 35.6174  \r\n\r\nThe only USC competition solver(45 minutes): \u003chttp://contest.usc.edu/index.php/Spring13/Home?action=download\u0026upname=thinice.zhengcao.cpp.txt Cao's C solution\u003e\r\n\r\n*Theory:*\r\n\r\nTraveling Salesman Optimum Route. (Matlab one line while)\r\n\r\nCreate Interconnect Matrix\r\n\r\nCalculate Route/Distances between Good-Ice using Polygon to Polygon distance function.\r\n\r\nPolygon to Polygon minimum distance uses minimum Point to Line Segment function.\r\n\r\n\r\n*Related Challenges:*\r\n\r\n1) \u003chttp://www.mathworks.com/matlabcentral/cody/problems/1446-minimum-distance-point-to-segment Minimum Distance Point to Segment\u003e\r\n\r\n2) \u003chttp://www.mathworks.com/matlabcentral/cody/problems/1452-minimum-distance-between-two-n-sided-polygons Minimum Distance between Polygons\u003e","description_html":"\u003cp\u003eThis Challenge is to solve the \u003ca href = \"http://contest.usc.edu/index.php/Spring13/Home\"\u003eUSC Spring 2013 ACM Contest\u003c/a\u003e Problem E, Walking on Thin Ice.\u003c/p\u003e\u003cp\u003eThe Rooster is crossing to the other side of the frozen river. Minimize his distance traveled on thin ice given a river width (w) and polygons(polycell) that denote non-thin ice regions. Start anywhere on the x-axis(y=0) and finish by reaching y=w.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e\u003c/p\u003e\u003cp\u003ew=120\u003c/p\u003e\u003cp\u003epolycell={[0 10 0 90 50 50 100 90 100 10] [0 110 100 110 50 70]};\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e 35.6174\u003c/p\u003e\u003cp\u003eThe only USC competition solver(45 minutes): \u003ca href = \"http://contest.usc.edu/index.php/Spring13/Home?action=download\u0026upname=thinice.zhengcao.cpp.txt\"\u003eCao's C solution\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eTheory:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eTraveling Salesman Optimum Route. (Matlab one line while)\u003c/p\u003e\u003cp\u003eCreate Interconnect Matrix\u003c/p\u003e\u003cp\u003eCalculate Route/Distances between Good-Ice using Polygon to Polygon distance function.\u003c/p\u003e\u003cp\u003ePolygon to Polygon minimum distance uses minimum Point to Line Segment function.\u003c/p\u003e\u003cp\u003e\u003cb\u003eRelated Challenges:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e1) \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/1446-minimum-distance-point-to-segment\"\u003eMinimum Distance Point to Segment\u003c/a\u003e\u003c/p\u003e\u003cp\u003e2) \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/1452-minimum-distance-between-two-n-sided-polygons\"\u003eMinimum Distance between Polygons\u003c/a\u003e\u003c/p\u003e","function_template":"function d=Thin_Ice(w,polycell)\r\n d=0;\r\n% pr=reshape(polycell{1},2,[])'; % example of first matrix to [x,y]\r\nend","test_suite":"tic\r\nw=50+randi(100,1) % case random 1 15\r\npymax=randi(50,1)\r\npolycell={[0 0 10 pymax 20 0]}; % case 1 15\r\nd=Thin_Ice(w,polycell)\r\nassert(abs(d-(w-pymax))\u003c.01)\r\ntoc\r\n%%\r\ntic\r\nw=110+randi(100,1); % case random 2\r\nw\r\npymax1=randi(30,1)\r\npymax2=randi(10,1)\r\npymax3=randi(10,1)\r\npolycell={[0 0 10 pymax1 pymax3 0] [-pymax2 30+pymax2 20+pymax1 30+pymax2 pymax1 40+pymax3]}; % case random\r\nd=Thin_Ice(w,polycell)\r\nassert(abs(d-(w-pymax1-(40+pymax3-(30+pymax2))))\u003c.01)\r\ntoc\r\n%%\r\n\r\ntic\r\nw=100; % case 1 15\r\npolycell={[0 0 10 85 20 0]}; % case 1 15\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-15)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=10; %case 2 5\r\npolycell={[-2 0 -2 2 2 2 2 0] [-2 5 -2 8 2 8 2 5]}; \r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-5)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=3618;% case 3 3598\r\npolycell={[550 201 546 211 555 221 564 211 560 201]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-3598)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=3618;% case 4 3593.57\r\npolycell={[550 201 546 211 555 221 564 211 560 201]...\r\n [570 211 566 221 575 231 584 221 580 211]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-3593.57)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=3618; % case 5 3598\r\npolycell={[550 201 546 211 555 221 564 211 560 201]...\r\n[1570 211 1566 221 1575 231 1584 221 1580 211]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-3598)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=10; %case 6 5\r\npolycell={[-2 0 -2 2 2 2 2 0]...\r\n[-10 5 -10 8 10 8 10 5]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-5)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=10000; %case 7 1615.15\r\npolycell={[-912000 8801 -912000 8881 -911001 8881 -911001 8801]...\r\n[-910000 9001 -910000 9087 -909001 9087 -909001 9001]...\r\n[ -993000 701 -993000 789 -992001 789 -992001 701]...\r\n[ -960000 4001 -960000 4082 -959001 4082 -959001 4001]...\r\n[ -984000 1601 -984000 1687 -983001 1687 -983001 1601]...\r\n[ -980000 2001 -980000 2089 -979001 2089 -979001 2001]...\r\n[ -942000 5801 -942000 5883 -941001 5883 -941001 5801]...\r\n[ -909000 9101 -909000 9185 -908001 9185 -908001 9101]...\r\n[ -967000 3301 -967000 3387 -966001 3387 -966001 3301]...\r\n[ -947000 5301 -947000 5382 -946001 5382 -946001 5301]...\r\n[ -908000 9201 -908000 9282 -907001 9282 -907001 9201]...\r\n[ -903000 9701 -903000 9781 -902001 9781 -902001 9701]...\r\n[ -951000 4901 -951000 4986 -950001 4986 -950001 4901]...\r\n[ -963000 3701 -963000 3788 -962001 3788 -962001 3701]...\r\n[ -973000 2701 -973000 2783 -972001 2783 -972001 2701]...\r\n[ -975000 2501 -975000 2584 -974001 2584 -974001 2501]...\r\n[ -994000 601 -994000 680 -993001 680 -993001 601]...\r\n[ -1000000 1 -1000000 86 -999001 86 -999001 1]...\r\n[ -999000 101 -999000 187 -998001 187 -998001 101]...\r\n[ -954000 4601 -954000 4686 -953001 4686 -953001 4601]...\r\n[ -930000 7001 -930000 7082 -929001 7082 -929001 7001]...\r\n[ -974000 2601 -974000 2680 -973001 2680 -973001 2601]...\r\n[ -926000 7401 -926000 7488 -925001 7488 -925001 7401]...\r\n[ -945000 5501 -945000 5583 -944001 5583 -944001 5501]...\r\n[ -956000 4401 -956000 4480 -955001 4480 -955001 4401]...\r\n[ -971000 2901 -971000 2987 -970001 2987 -970001 2901]...\r\n[ -933000 6701 -933000 6789 -932001 6789 -932001 6701]...\r\n[ -976000 2401 -976000 2482 -975001 2482 -975001 2401]...\r\n[ -970000 3001 -970000 3086 -969001 3086 -969001 3001]...\r\n[ -981000 1901 -981000 1989 -980001 1989 -980001 1901]...\r\n[ -955000 4501 -955000 4580 -954001 4580 -954001 4501]...\r\n[ -950000 5001 -950000 5088 -949001 5088 -949001 5001]...\r\n[ -906000 9401 -906000 9481 -905001 9481 -905001 9401]...\r\n[ -927000 7301 -927000 7386 -926001 7386 -926001 7301]...\r\n[ -911000 8901 -911000 8987 -910001 8987 -910001 8901]...\r\n[ -928000 7201 -928000 7282 -927001 7282 -927001 7201]...\r\n[ -996000 401 -996000 480 -995001 480 -995001 401]...\r\n[ -966000 3401 -966000 3483 -965001 3483 -965001 3401]...\r\n[ -925000 7501 -925000 7588 -924001 7588 -924001 7501]...\r\n[ -905000 9501 -905000 9587 -904001 9587 -904001 9501]...\r\n[ -943000 5701 -943000 5785 -942001 5785 -942001 5701]...\r\n[ -990000 1001 -990000 1087 -989001 1087 -989001 1001]...\r\n[ -948000 5201 -948000 5288 -947001 5288 -947001 5201]...\r\n[ -968000 3201 -968000 3281 -967001 3281 -967001 3201]...\r\n[ -989000 1101 -989000 1180 -988001 1180 -988001 1101]...\r\n[ -935000 6501 -935000 6587 -934001 6587 -934001 6501]...\r\n[ -936000 6401 -936000 6484 -935001 6484 -935001 6401]...\r\n[ -998000 201 -998000 283 -997001 283 -997001 201]...\r\n[ -932000 6801 -932000 6886 -931001 6886 -931001 6801]...\r\n[ -918000 8201 -918000 8282 -917001 8282 -917001 8201]...\r\n[ -916000 8401 -916000 8486 -915001 8486 -915001 8401]...\r\n[ -952000 4801 -952000 4880 -951001 4880 -951001 4801]...\r\n[ -992000 801 -992000 886 -991001 886 -991001 801]...\r\n[ -913000 8701 -913000 8786 -912001 8786 -912001 8701]...\r\n[ -901000 9901 -901000 9989 -900001 9989 -900001 9901]...\r\n[ -962000 3801 -962000 3887 -961001 3887 -961001 3801]...\r\n[ -902000 9801 -902000 9884 -901001 9884 -901001 9801]...\r\n[ -917000 8301 -917000 8384 -916001 8384 -916001 8301]...\r\n[ -985000 1501 -985000 1583 -984001 1583 -984001 1501]...\r\n[ -979000 2101 -979000 2188 -978001 2188 -978001 2101]...\r\n[ -940000 6001 -940000 6088 -939001 6088 -939001 6001]...\r\n[ -988000 1201 -988000 1282 -987001 1282 -987001 1201]...\r\n[ -904000 9601 -904000 9687 -903001 9687 -903001 9601]...\r\n[ -922000 7801 -922000 7885 -921001 7885 -921001 7801]...\r\n[ -929000 7101 -929000 7188 -928001 7188 -928001 7101]...\r\n[ -907000 9301 -907000 9389 -906001 9389 -906001 9301]...\r\n[ -997000 301 -997000 381 -996001 381 -996001 301]...\r\n[ -939000 6101 -939000 6181 -938001 6181 -938001 6101]...\r\n[ -983000 1701 -983000 1787 -982001 1787 -982001 1701]...\r\n[ -978000 2201 -978000 2285 -977001 2285 -977001 2201]...\r\n[ -944000 5601 -944000 5686 -943001 5686 -943001 5601]...\r\n[ -987000 1301 -987000 1382 -986001 1382 -986001 1301]...\r\n[ -986000 1401 -986000 1484 -985001 1484 -985001 1401]...\r\n[ -982000 1801 -982000 1887 -981001 1887 -981001 1801]...\r\n[ -934000 6601 -934000 6687 -933001 6687 -933001 6601]...\r\n[ -972000 2801 -972000 2884 -971001 2884 -971001 2801]...\r\n[ -938000 6201 -938000 6282 -937001 6282 -937001 6201]...\r\n[ -964000 3601 -964000 3685 -963001 3685 -963001 3601]...\r\n[ -915000 8501 -915000 8586 -914001 8586 -914001 8501]...\r\n[ -937000 6301 -937000 6383 -936001 6383 -936001 6301]...\r\n[ -919000 8101 -919000 8187 -918001 8187 -918001 8101]...\r\n[ -949000 5101 -949000 5186 -948001 5186 -948001 5101]...\r\n[ -953000 4701 -953000 4782 -952001 4782 -952001 4701]...\r\n[ -959000 4101 -959000 4188 -958001 4188 -958001 4101]...\r\n[ -961000 3901 -961000 3988 -960001 3988 -960001 3901]...\r\n[ -920000 8001 -920000 8088 -919001 8088 -919001 8001]...\r\n[ -931000 6901 -931000 6981 -930001 6981 -930001 6901]...\r\n[ -914000 8601 -914000 8686 -913001 8686 -913001 8601]...\r\n[ -924000 7601 -924000 7687 -923001 7687 -923001 7601]...\r\n[ -923000 7701 -923000 7789 -922001 7789 -922001 7701]...\r\n[ -965000 3501 -965000 3584 -964001 3584 -964001 3501]...\r\n[ -958000 4201 -958000 4280 -957001 4280 -957001 4201]...\r\n[ -991000 901 -991000 989 -990001 989 -990001 901]...\r\n[ -957000 4301 -957000 4383 -956001 4383 -956001 4301]...\r\n[ -969000 3101 -969000 3187 -968001 3187 -968001 3101]...\r\n[ -977000 2301 -977000 2388 -976001 2388 -976001 2301]...\r\n[ -946000 5401 -946000 5484 -945001 5484 -945001 5401]...\r\n[ -995000 501 -995000 589 -994001 589 -994001 501]...\r\n[ -921000 7901 -921000 7983 -920001 7983 -920001 7901]...\r\n[ -941000 5901 -941000 5981 -940001 5981 -940001 5901]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-1615.15)\u003c.01)\r\ntoc\r\n\r\n%%\r\ntic\r\nw=11000; % case 8 1536.76\r\npolycell={[-918919 8101 -918919 8197 -917920 8197 -917920 8101]...\r\n[ -965966 3401 -965966 3502 -964967 3502 -964967 3401]...\r\n[ -989990 1001 -989990 1126 -988991 1126 -988991 1001]...\r\n[ -940941 5901 -940941 5984 -939942 5984 -939942 5901]...\r\n[ -975976 2401 -975976 2489 -974977 2489 -974977 2401]...\r\n[ -968969 3101 -968969 3207 -967970 3207 -967970 3101]...\r\n[ -957958 4201 -957958 4296 -956959 4296 -956959 4201]...\r\n[ -970971 2901 -970971 3021 -969972 3021 -969972 2901]...\r\n[ -927928 7201 -927928 7325 -926929 7325 -926929 7201]...\r\n[ -956957 4301 -956957 4382 -955958 4382 -955958 4301]...\r\n[ -947948 5201 -947948 5296 -946949 5296 -946949 5201]...\r\n[ -988989 1101 -988989 1225 -987990 1225 -987990 1101]...\r\n[ -915916 8401 -915916 8497 -914917 8497 -914917 8401]...\r\n[ -907908 9201 -907908 9294 -906909 9294 -906909 9201]...\r\n[ -997998 201 -997998 289 -996999 289 -996999 201]...\r\n[ -911912 8801 -911912 8908 -910913 8908 -910913 8801]...\r\n[ -972973 2701 -972973 2826 -971974 2826 -971974 2701]...\r\n[ -952953 4701 -952953 4817 -951954 4817 -951954 4701]...\r\n[ -980981 1901 -980981 2010 -979982 2010 -979982 1901]...\r\n[ -932933 6701 -932933 6783 -931934 6783 -931934 6701]...\r\n[ -964965 3501 -964965 3609 -963966 3609 -963966 3501]...\r\n[ -978979 2101 -978979 2194 -977980 2194 -977980 2101]...\r\n[ -925926 7401 -925926 7505 -924927 7505 -924927 7401]...\r\n[ -973974 2601 -973974 2703 -972975 2703 -972975 2601]...\r\n[ -990991 901 -990991 1002 -989992 1002 -989992 901]...\r\n[ -966967 3301 -966967 3389 -965968 3389 -965968 3301]...\r\n[ -977978 2201 -977978 2297 -976979 2297 -976979 2201]...\r\n[ -945946 5401 -945946 5505 -944947 5505 -944947 5401]...\r\n[ -938939 6101 -938939 6229 -937940 6229 -937940 6101]...\r\n[ -909910 9001 -909910 9080 -908911 9080 -908911 9001]...\r\n[ -924925 7501 -924925 7629 -923926 7629 -923926 7501]...\r\n[ -900901 9901 -900901 10022 -899902 10022 -899902 9901]...\r\n[ -954955 4501 -954955 4605 -953956 4605 -953956 4501]...\r\n[ -926927 7301 -926927 7382 -925928 7382 -925928 7301]...\r\n[ -905906 9401 -905906 9507 -904907 9507 -904907 9401]...\r\n[ -981982 1801 -981982 1892 -980983 1892 -980983 1801]...\r\n[ -1000000 1 -1000000 102 -999001 102 -999001 1]...\r\n[ -930931 6901 -930931 7023 -929932 7023 -929932 6901]...\r\n[ -959960 4001 -959960 4123 -958961 4123 -958961 4001]...\r\n[ -917918 8201 -917918 8319 -916919 8319 -916919 8201]...\r\n[ -942943 5701 -942943 5794 -941944 5794 -941944 5701]...\r\n[ -941942 5801 -941942 5880 -940943 5880 -940943 5801]...\r\n[ -901902 9801 -901902 9922 -900903 9922 -900903 9801]...\r\n[ -995996 401 -995996 510 -994997 510 -994997 401]...\r\n[ -903904 9601 -903904 9683 -902905 9683 -902905 9601]...\r\n[ -914915 8501 -914915 8623 -913916 8623 -913916 8501]...\r\n[ -998999 101 -998999 192 -998000 192 -998000 101]...\r\n[ -921922 7801 -921922 7885 -920923 7885 -920923 7801]...\r\n[ -969970 3001 -969970 3116 -968971 3116 -968971 3001]...\r\n[ -912913 8701 -912913 8812 -911914 8812 -911914 8701]...\r\n[ -987988 1201 -987988 1328 -986989 1328 -986989 1201]...\r\n[ -902903 9701 -902903 9827 -901904 9827 -901904 9701]...\r\n[ -982983 1701 -982983 1815 -981984 1815 -981984 1701]...\r\n[ -920921 7901 -920921 8002 -919922 8002 -919922 7901]...\r\n[ -971972 2801 -971972 2891 -970973 2891 -970973 2801]...\r\n[ -979980 2001 -979980 2107 -978981 2107 -978981 2001]...\r\n[ -939940 6001 -939940 6085 -938941 6085 -938941 6001]...\r\n[ -906907 9301 -906907 9416 -905908 9416 -905908 9301]...\r\n[ -951952 4801 -951952 4889 -950953 4889 -950953 4801]...\r\n[ -946947 5301 -946947 5404 -945948 5404 -945948 5301]...\r\n[ -961962 3801 -961962 3905 -960963 3905 -960963 3801]...\r\n[ -916917 8301 -916917 8404 -915918 8404 -915918 8301]...\r\n[ -983984 1601 -983984 1680 -982985 1680 -982985 1601]...\r\n[ -937938 6201 -937938 6290 -936939 6290 -936939 6201]...\r\n[ -963964 3601 -963964 3693 -962965 3693 -962965 3601]...\r\n[ -922923 7701 -922923 7814 -921924 7814 -921924 7701]...\r\n[ -962963 3701 -962963 3816 -961964 3816 -961964 3701]...\r\n[ -931932 6801 -931932 6890 -930933 6890 -930933 6801]...\r\n[ -960961 3901 -960961 4021 -959962 4021 -959962 3901]...\r\n[ -984985 1501 -984985 1624 -983986 1624 -983986 1501]...\r\n[ -992993 701 -992993 810 -991994 810 -991994 701]...\r\n[ -986987 1301 -986987 1390 -985988 1390 -985988 1301]...\r\n[ -955956 4401 -955956 4504 -954957 4504 -954957 4401]...\r\n[ -919920 8001 -919920 8086 -918921 8086 -918921 8001]...\r\n[ -944945 5501 -944945 5613 -943946 5613 -943946 5501]...\r\n[ -943944 5601 -943944 5718 -942945 5718 -942945 5601]...\r\n[ -974975 2501 -974975 2590 -973976 2590 -973976 2501]...\r\n[ -913914 8601 -913914 8696 -912915 8696 -912915 8601]...\r\n[ -923924 7601 -923924 7692 -922925 7692 -922925 7601]...\r\n[ -985986 1401 -985986 1491 -984987 1491 -984987 1401]...\r\n[ -996997 301 -996997 387 -995998 387 -995998 301]...\r\n[ -934935 6501 -934935 6623 -933936 6623 -933936 6501]...\r\n[ -953954 4601 -953954 4720 -952955 4720 -952955 4601]...\r\n[ -933934 6601 -933934 6702 -932935 6702 -932935 6601]...\r\n[ -991992 801 -991992 893 -990993 893 -990993 801]...\r\n[ -910911 8901 -910911 9000 -909912 9000 -909912 8901]...\r\n[ -967968 3201 -967968 3298 -966969 3298 -966969 3201]...\r\n[ -908909 9101 -908909 9219 -907910 9219 -907910 9101]...\r\n[ -949950 5001 -949950 5113 -948951 5113 -948951 5001]...\r\n[ -993994 601 -993994 717 -992995 717 -992995 601]...\r\n[ -948949 5101 -948949 5199 -947950 5199 -947950 5101]...\r\n[ -950951 4901 -950951 5014 -949952 5014 -949952 4901]...\r\n[ -958959 4101 -958959 4218 -957960 4218 -957960 4101]...\r\n[ -928929 7101 -928929 7196 -927930 7196 -927930 7101]...\r\n[ -904905 9501 -904905 9604 -903906 9604 -903906 9501]...\r\n[ -976977 2301 -976977 2422 -975978 2422 -975978 2301]...\r\n[ -929930 7001 -929930 7122 -928931 7122 -928931 7001]...\r\n[ -994995 501 -994995 607 -993996 607 -993996 501]...\r\n[ -935936 6401 -935936 6515 -934937 6515 -934937 6401]...\r\n[ -936937 6301 -936937 6415 -935938 6415 -935938 6301]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-1536.76)\u003c.01)\r\ntoc\r\n\r\n\r\n%%\r\ntic\r\nw=120;%case 9 35.62\r\npolycell={[0 10 0 90 50 50 100 90 100 10]...\r\n [0 110 100 110 50 70]};\r\nd=Thin_Ice(w,polycell);\r\nassert(abs(d-35.6174)\u003c.01)\r\ntoc\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2,"test_suite_updated_at":"2013-04-25T19:40:38.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-04-25T04:08:54.000Z","updated_at":"2013-04-25T19:40:38.000Z","published_at":"2013-04-25T19:40:38.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\u003eThis Challenge is to solve 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=\\\"http://contest.usc.edu/index.php/Spring13/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC Spring 2013 ACM Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e Problem E, Walking on Thin Ice.\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 Rooster is crossing to the other side of the frozen river. Minimize his distance traveled on thin ice given a river width (w) and polygons(polycell) that denote non-thin ice regions. Start anywhere on the x-axis(y=0) and finish by reaching y=w.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\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\u003ew=120\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\u003epolycell={[0 10 0 90 50 50 100 90 100 10] [0 110 100 110 50 70]};\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 35.6174\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 only USC competition solver(45 minutes):\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Spring13/Home?action=download\u0026amp;upname=thinice.zhengcao.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCao's C solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTheory:\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\u003eTraveling Salesman Optimum Route. (Matlab one line while)\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\u003eCreate Interconnect Matrix\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\u003eCalculate Route/Distances between Good-Ice using Polygon to Polygon distance function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePolygon to Polygon minimum distance uses minimum Point to Line Segment function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRelated Challenges:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/1446-minimum-distance-point-to-segment\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMinimum Distance Point to Segment\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e2)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/1452-minimum-distance-between-two-n-sided-polygons\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMinimum Distance between Polygons\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":1101,"title":"USC Fall 2012 ACM : Chemical Analysis","description":"This Challenge is to solve Question D, Chemical Analysis, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nGiven an array M of Element Spectral signatures(m elements by n Spectra) and a Sample spectra of width n, determine the minimum number of elements that could generate the Sample's spectra.\r\n\r\n\r\nInput: [ A, Sample ]\r\n\r\nOutput: min_elements; \r\n\r\nThe minimum number Components to create the Sample Spectra. If no combination exists then output 0.\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=analysis.in.txt USC data file\u003e\r\n\r\nInput: [1 1 0 0;0 1 1 1;0 1 1 0;0 1 0 1], [1 1 0 1]\r\n\r\nOutput: 2 as [1 1 0 0] and [0 1 0 1] can create [1 1 0 1]\r\n\r\n\r\n\r\nThe Winning C solution is in the Test Suite to assist - not likely.\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question D, Chemical Analysis, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGiven an array M of Element Spectral signatures(m elements by n Spectra) and a Sample spectra of width n, determine the minimum number of elements that could generate the Sample's spectra.\u003c/p\u003e\u003cp\u003eInput: [ A, Sample ]\u003c/p\u003e\u003cp\u003eOutput: min_elements;\u003c/p\u003e\u003cp\u003eThe minimum number Components to create the Sample Spectra. If no combination exists then output 0.\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=analysis.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003eInput: [1 1 0 0;0 1 1 1;0 1 1 0;0 1 0 1], [1 1 0 1]\u003c/p\u003e\u003cp\u003eOutput: 2 as [1 1 0 0] and [0 1 0 1] can create [1 1 0 1]\u003c/p\u003e\u003cp\u003eThe Winning C solution is in the Test Suite to assist - not likely.\u003c/p\u003e","function_template":"function min_elements=Chem_analysis(A,Sample) \r\n min_elements=0;\r\nend","test_suite":"%%\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=analysis.in.txt','analysis_in.txt')\r\ntoc\r\n%%\r\n fid=fopen('analysis_in.txt','r');\r\n min_elements_expected=[2 0 1 2 0 3 4];\r\n\r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty\r\n  n = fscanf(fid,'%i %i\\n',2)'; % cols / rows\r\n   \r\n  A=zeros(n)'; % Format is colmns, rows\r\n  for i=1:n(2)\r\n   strv = fgetl(fid);\r\n   A(i,:) = strv - '0';\r\n  end\r\n   strv=fgetl(fid);\r\n   Sample=strv - '0';\r\n    \r\n  min_elements=Chem_analysis(A,Sample);\r\n    \r\n  assert(isequal(min_elements,min_elements_expected(q)));\r\n end % for q\r\n \r\n fclose(fid);\r\n\r\n\r\n% The C Winning Solution\r\n% #include \u003ciostream\u003e\r\n% #include \u003cfstream\u003e\r\n% #include \u003cstring\u003e\r\n% using namespace std;\r\n% int testcases;\r\n% int n, m;\r\n% int now;\r\n% int best;\r\n% string goal;\r\n% string s[1000];\r\n% void search(int i, string status)\r\n% {\r\n% \tif (i == n)\r\n% \t{\r\n% \t\tif (status == goal)\r\n% \t\t{\r\n% \t\t if ((best \u003c 0) || (now \u003c best)) best = now;\r\n% \t\t}\r\n% \t\treturn;\r\n% \t}\r\n% \tsearch(i + 1, status);\r\n% \tstring tmp = status;\r\n% \tfor (int j = 0; j \u003c m; j ++)\r\n% \t{\r\n% \t\tif (s[i][j] == '1') tmp[j] = '1';\r\n% \t}\r\n% \tnow ++;\r\n% \tsearch(i + 1, tmp);\r\n% \tnow --;\r\n% }\r\n% int main()\r\n% {\r\n% \tifstream inf(\"analysis.in\");\r\n% \tinf \u003e\u003e testcases;\r\n% \tfor (int testcase = 1; testcase \u003c= testcases; testcase ++)\r\n% \t{\r\n% \t\tcout \u003c\u003c \"Data Set \" \u003c\u003c testcase \u003c\u003c \":\" \u003c\u003c endl;\r\n% \t\tinf \u003e\u003e m \u003e\u003e n;\r\n% \t\tfor (int i = 0; i \u003c n; i ++)\r\n% \t\t\tinf \u003e\u003e s[i];\r\n% \t\tinf \u003e\u003e goal;\r\n% \t\tbest = -1;\r\n% \t\tstring ini = \"\";\r\n% \t\tfor (int i = 0; i \u003c m; i ++)\r\n% \t\t\tini = ini + \"0\";\r\n% \t\tnow = 0;\r\n% \t\tsearch(0, ini);\r\n%  if (best \u003c 0) cout \u003c\u003c \"Impossible\" \u003c\u003c endl; else cout \u003c\u003c best \u003c\u003c endl;\r\n% \t\tcout \u003c\u003c endl;\r\n% \t}\r\n% \tinf.close();\r\n% \treturn 0;\r\n% }\r\n% \r\n%\r\n%\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-06T20:21:50.000Z","updated_at":"2012-12-06T20:32:33.000Z","published_at":"2012-12-06T20:32:33.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\u003eThis Challenge is to solve Question D, Chemical Analysis, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an array M of Element Spectral signatures(m elements by n Spectra) and a Sample spectra of width n, determine the minimum number of elements that could generate the Sample's spectra.\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\u003eInput: [ A, Sample ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: min_elements;\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 minimum number Components to create the Sample Spectra. If no combination exists then output 0.\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=analysis.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eInput: [1 1 0 0;0 1 1 1;0 1 1 0;0 1 0 1], [1 1 0 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: 2 as [1 1 0 0] and [0 1 0 1] can create [1 1 0 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Winning C solution is in the Test Suite to assist - not likely.\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":1102,"title":"USC Fall 2012 ACM : Find Largest Water Concentration","description":"This Challenge is to solve Question B, Water?, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nGiven a character array A of minerals(A:Z) and a vector, iswater, of Water bearing minerals(A:Z) and a minimum rectangular size to evaluate, determine the Region with the Maximum water density. Report the larger region if two have the same density. \r\n\r\nSpecifically, report the Total water symbols and the Area of the highest density region. \r\n\r\n\r\nInput: [ A, iswater, s ]\r\n\r\nOutput: [Total Water Symbols, Area of Rectangle]; \r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.in.txt USC data file\u003e\r\n\r\nExample:\r\n\r\nInput: A, iswater, s\r\n\r\n  Matrix A\r\n  ITTTTHHHHTTTT\r\n  IXYOXOOOOOOXI\r\n  IOOOXOOOOOXXJ\r\n  IYOOOOXOOOOOI\r\n  IXXOYOOYOOOOI\r\n  IAAAAAXAXAAAJ\r\n  \r\n  iswater vector\r\n  YX\r\n  \r\n  s is 3; This is the minimum allowed rectangle size\r\n  \r\n\r\nOutput: [8 16] as there are 8 \"water symbols\" in a 4x4=16 square TLC:(2,2)\r\n\r\n\r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.rongqiqiu.cpp.txt The Winning B solution\u003e is very large.\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question B, Water?, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGiven a character array A of minerals(A:Z) and a vector, iswater, of Water bearing minerals(A:Z) and a minimum rectangular size to evaluate, determine the Region with the Maximum water density. Report the larger region if two have the same density.\u003c/p\u003e\u003cp\u003eSpecifically, report the Total water symbols and the Area of the highest density region.\u003c/p\u003e\u003cp\u003eInput: [ A, iswater, s ]\u003c/p\u003e\u003cp\u003eOutput: [Total Water Symbols, Area of Rectangle];\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003eInput: A, iswater, s\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eMatrix A\r\nITTTTHHHHTTTT\r\nIXYOXOOOOOOXI\r\nIOOOXOOOOOXXJ\r\nIYOOOOXOOOOOI\r\nIXXOYOOYOOOOI\r\nIAAAAAXAXAAAJ\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eiswater vector\r\nYX\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003es is 3; This is the minimum allowed rectangle size\r\n\u003c/pre\u003e\u003cp\u003eOutput: [8 16] as there are 8 \"water symbols\" in a 4x4=16 square TLC:(2,2)\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.rongqiqiu.cpp.txt\"\u003eThe Winning B solution\u003c/a\u003e is very large.\u003c/p\u003e","function_template":"function [w,w_area]=Water_analysis(A,iswater,s) \r\n w=0;\r\n w_area=s^2;\r\n \r\nend","test_suite":"%%\r\n%http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.in.txt\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=water.in.txt','water_in.txt');\r\ntoc\r\n%%\r\n fid=fopen('water_in.txt','r');\r\n w_area_expect=[8 16;100 100;0 1;1 1;5 9;186 675;23 110; 480 2500;102 2500;61 400; ...\r\n     73 930;160 441; 678 800; 55 361; 53 195;216 1296;199 1110;81 576;232 552;12 30;9 25;15 25;25 143; ...\r\n     66 120;2500 2500;270 1680;264 900;292 1365;748 2401;244 609;315 1296;214 1188];\r\n \r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty\r\n  n = fscanf(fid,'%i %i %i\\n',3)'; % rows / cols / min rect\r\n  s=n(3);\r\n  n=n(1:2);\r\n \r\n  strv=fgetl(fid);\r\n  iswater=strv;\r\n  \r\n  A=zeros(n); % Format is rows, columns\r\n  for i=1:n(1)\r\n   strv = fgetl(fid);\r\n   A(i,:) = strv;\r\n  end\r\n  A=char(A);\r\n\r\n  [w,w_area]=Water_analysis(A,iswater,s);\r\n  \r\n  assert(isequal([w w_area],w_area_expect(q,:)));\r\n\r\n end\r\n \r\n fprintf('Processing Complete\\n\\n')\r\n fclose(fid);\r\ntoc\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-07T02:38:08.000Z","updated_at":"2025-11-21T09:56:08.000Z","published_at":"2012-12-07T04:04:40.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\u003eThis Challenge is to solve Question B, Water?, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a character array A of minerals(A:Z) and a vector, iswater, of Water bearing minerals(A:Z) and a minimum rectangular size to evaluate, determine the Region with the Maximum water density. Report the larger region if two have the same density.\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\u003eSpecifically, report the Total water symbols and the Area of the highest density region.\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\u003eInput: [ A, iswater, s ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: [Total Water Symbols, Area of Rectangle];\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput: A, iswater, s\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[Matrix A\\nITTTTHHHHTTTT\\nIXYOXOOOOOOXI\\nIOOOXOOOOOXXJ\\nIYOOOOXOOOOOI\\nIXXOYOOYOOOOI\\nIAAAAAXAXAAAJ\\n\\niswater vector\\nYX\\n\\ns is 3; This is the minimum allowed rectangle size]]\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\u003eOutput: [8 16] as there are 8 \\\"water symbols\\\" in a 4x4=16 square TLC:(2,2)\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=water.rongqiqiu.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Winning B solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is very large.\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":1109,"title":"USC Spring 2012 ACM: Armageddon","description":"This Challenge is to solve Question E, Armageddon, of the \u003chttp://contest.usc.edu/index.php/Spring12/Home USC ACM Spring 2012 Contest\u003e.\r\n\r\nAn asteroid has been detected that will traverse the center of the earth if it is not deflected. The Splitter missile will bisect the asteroid with an included angle (\u003e0, \u003c180 degrees), based on its composition. The asteroids distance(to center of earth), velocity, and split angle will be provided. The Splitter missile velocity is also provided. Launch occurs from the earth surface nearest the asteroid. Miscellaneous details: Earth Radius 6378.1 km, velocities in km/sec, distance in km\r\n, and angle in degrees.\r\n\r\nReturn the Maximum Time Prior to Launch, nothing hitting the earth, to two decimal places. \r\n\r\n\r\n*Input: [ Asteroid Distance, Angle of Split, Asteroid Velocity, Missile Velocity ]*\r\n\r\n*Output: [Maximum Time Prior to Launch]*; if too late return -1;\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Spring12/Home?action=download\u0026upname=armageddon.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: 63781.0 20.9514 6378.1 6378.1*\r\n\r\n*Output: 0.00* as immediate Launch is required  \r\n\r\nInput 47835.75,15,6000,5000 returns -1.\r\n\r\n\r\n\u003chttp://contest.usc.edu/index.php/Spring12/Home?action=download\u0026upname=numerology_darryl.cpp.txt The Judges' E solution\u003e.\r\n\r\nGeometry Hint: Draw a circle and a line from the center of  approximately 2 radius. Take a ruler pivoting from the end of the line and rotate the ruler until it touches the circle.\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question E, Armageddon, of the \u003ca href=\"http://contest.usc.edu/index.php/Spring12/Home\"\u003eUSC ACM Spring 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eAn asteroid has been detected that will traverse the center of the earth if it is not deflected. The Splitter missile will bisect the asteroid with an included angle (\u003e0, \u0026lt;180 degrees), based on its composition. The asteroids distance(to center of earth), velocity, and split angle will be provided. The Splitter missile velocity is also provided. Launch occurs from the earth surface nearest the asteroid. Miscellaneous details: Earth Radius 6378.1 km, velocities in km/sec, distance in km\r\n, and angle in degrees.\u003c/p\u003e\u003cp\u003eReturn the Maximum Time Prior to Launch, nothing hitting the earth, to two decimal places.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [ Asteroid Distance, Angle of Split, Asteroid Velocity, Missile Velocity ]\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [Maximum Time Prior to Launch]\u003c/b\u003e; if too late return -1;\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=armageddon.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: 63781.0 20.9514 6378.1 6378.1\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: 0.00\u003c/b\u003e as immediate Launch is required\u003c/p\u003e\u003cp\u003eInput 47835.75,15,6000,5000 returns -1.\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=numerology_darryl.cpp.txt\"\u003eThe Judges' E solution\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eGeometry Hint: Draw a circle and a line from the center of  approximately 2 radius. Take a ruler pivoting from the end of the line and rotate the ruler until it touches the circle.\u003c/p\u003e","function_template":"function [t_launch]=Armageddon(xa,angle,va,vm)\r\n  t_launch=-1;\r\nend","test_suite":"%%\r\n% Armegeddon\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026upname=armageddon.in.txt','armageddon.in.txt')\r\ntoc\r\n%%\r\n fid=fopen('armageddon.in.txt','r');\r\n \r\n t_expect=[0.00 -1 20.55 -1 -1 28.38 -1 11.03 2.62 4.22 13.15 9.94 61.33 13.56 -1];\r\n \r\n  \r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty %qty\r\n  n = fscanf(fid,'%f %f %f %f \\n',4)'; % dist, angle, vel A, vel Missile\r\n  xa=n(1);\r\n  angle=n(2);\r\n  va=n(3);\r\n  vm=n(4);\r\n  \r\n  [t]=Armageddon(xa,angle,va,vm) ;\r\n  \r\n  \r\n  assert(isequal(t,t_expect(q)))\r\n  \r\n   \r\n  end\r\n   \r\n fclose(fid);\r\ntoc","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":"2012-12-09T06:02:07.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-08T21:43:00.000Z","updated_at":"2012-12-09T15:08:14.000Z","published_at":"2012-12-08T22:02:35.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\u003eThis Challenge is to solve Question E, Armageddon, of 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=\\\"http://contest.usc.edu/index.php/Spring12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Spring 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAn asteroid has been detected that will traverse the center of the earth if it is not deflected. The Splitter missile will bisect the asteroid with an included angle (\u0026gt;0, \u0026lt;180 degrees), based on its composition. The asteroids distance(to center of earth), velocity, and split angle will be provided. The Splitter missile velocity is also provided. Launch occurs from the earth surface nearest the asteroid. Miscellaneous details: Earth Radius 6378.1 km, velocities in km/sec, distance in km , and angle in degrees.\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\u003eReturn the Maximum Time Prior to Launch, nothing hitting the earth, to two 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [ Asteroid Distance, Angle of Split, Asteroid Velocity, Missile Velocity ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [Maximum Time Prior to Launch]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; if too late return -1;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=armageddon.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: 63781.0 20.9514 6378.1 6378.1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: 0.00\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as immediate Launch is required\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\u003eInput 47835.75,15,6000,5000 returns -1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Spring12/Home?action=download\u0026amp;upname=numerology_darryl.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Judges' E solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGeometry Hint: Draw a circle and a line from the center of approximately 2 radius. Take a ruler pivoting from the end of the line and rotate the ruler until it touches the circle.\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":1115,"title":"USC Fall 2012 ACM: Driving the Rover","description":"This Challenge is to solve Question E, Driving the Rover, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nThe Rover is sent a Series of commands. Your task is to emulate the Rover response to the sequence and determine its \"final position\", [x,y]. The \"final position\" is the Rover location 1 second after the final command.\r\n\r\n  Initial conditions are Rover Stopped and Facing +Y.\r\n  Commands are processed at 1 second intervals\r\n  \r\n  Commands and their attributes:\r\n  FORWARD: Starts rolling forward at 1 cm/s\r\n  BACKWARDS: Roll backwards at 1 cm/s\r\n  FASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\n  SLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\n  STOP: Halts rover movement\r\n  RIGHT: Turn rover 90 degrees to the right\r\n  LEFT: Turn the rover 90 degrees to the left\r\n  NOOP: No change in anything \r\n\r\n\r\n  Commands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\r\n  Commands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\r\n\r\n*Input: [Cell array of Rover Commands]*\r\n\r\n*Output: [x, y ]*; Final Position 1 second after last command;\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=driving.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: {'FORWARD' 'RIGHT' 'STOP' 'RIGHT' 'FORWARD' 'FASTER'}*\r\n\r\n*Output: [3 2]* as the first RIGHT is ignored \r\n \r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=driving.bozhang.cpp.txt A Contest Drive solution\u003e.  Time to Solve: 9 minutes. Start.\r\n\r\nThis is predecessor to the Martian Pits Challenge.\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question E, Driving the Rover, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eThe Rover is sent a Series of commands. Your task is to emulate the Rover response to the sequence and determine its \"final position\", [x,y]. The \"final position\" is the Rover location 1 second after the final command.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInitial conditions are Rover Stopped and Facing +Y.\r\nCommands are processed at 1 second intervals\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands and their attributes:\r\nFORWARD: Starts rolling forward at 1 cm/s\r\nBACKWARDS: Roll backwards at 1 cm/s\r\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\nSTOP: Halts rover movement\r\nRIGHT: Turn rover 90 degrees to the right\r\nLEFT: Turn the rover 90 degrees to the left\r\nNOOP: No change in anything \r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput: [Cell array of Rover Commands]\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [x, y ]\u003c/b\u003e; Final Position 1 second after last command;\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: {'FORWARD' 'RIGHT' 'STOP' 'RIGHT' 'FORWARD' 'FASTER'}\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [3 2]\u003c/b\u003e as the first RIGHT is ignored\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.bozhang.cpp.txt\"\u003eA Contest Drive solution\u003c/a\u003e.  Time to Solve: 9 minutes. Start.\u003c/p\u003e\u003cp\u003eThis is predecessor to the Martian Pits Challenge.\u003c/p\u003e","function_template":"function xy=Drive(m)\r\n  xy=[0,0];\r\nend","test_suite":"%%\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=driving.in.txt','driving.in.txt');\r\ntoc\r\n%%\r\n fid=fopen('driving.in.txt','r');\r\n xy_expect=[3 2;2 29;107 23;-79 -72];\r\n \r\n qty=fscanf(fid,'%i',1);\r\n for q=1:qty %qty\r\n  n = fscanf(fid,'%f\\n',1); % commands\r\n  m=cell(n,1);\r\n  for i=1:n\r\n   m{i}=fgetl(fid);\r\n  end\r\n \r\n   [xy]=Drive(m) ;\r\n   assert(isequal(xy,xy_expect(q,:)))\r\n%   fprintf('Q %i  x %i  y %i  Pass %i\\n',q,xy,tf)\r\n   \r\n  \r\n end % q\r\n \r\n fclose(fid);\r\ntoc","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-12-12T03:32:42.000Z","updated_at":"2012-12-12T04:06:15.000Z","published_at":"2012-12-12T04:06:15.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\u003eThis Challenge is to solve Question E, Driving the Rover, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Rover is sent a Series of commands. Your task is to emulate the Rover response to the sequence and determine its \\\"final position\\\", [x,y]. The \\\"final position\\\" is the Rover location 1 second after the final command.\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[Initial conditions are Rover Stopped and Facing +Y.\\nCommands are processed at 1 second intervals\\n\\nCommands and their attributes:\\nFORWARD: Starts rolling forward at 1 cm/s\\nBACKWARDS: Roll backwards at 1 cm/s\\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \\\"Stopped\\\"\\nSTOP: Halts rover movement\\nRIGHT: Turn rover 90 degrees to the right\\nLEFT: Turn the rover 90 degrees to the left\\nNOOP: No change in anything \\n\\nCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\\n\\nCommands FASTER and SLOWER only take effect if the rover is moving forward.]]\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [Cell array of Rover Commands]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [x, y ]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; Final Position 1 second after last command;\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: {'FORWARD' 'RIGHT' 'STOP' 'RIGHT' 'FORWARD' 'FASTER'}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [3 2]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as the first RIGHT is ignored\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=driving.bozhang.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eA Contest Drive solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Time to Solve: 9 minutes. Start.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is predecessor to the Martian Pits Challenge.\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":1110,"title":"USC Fall 2012 ACM: Martian Pranks","description":"This Challenge is to solve Question C, Martian Pranks, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nRocks are moving between Rover pictures. This proves Life on Mars, but how Fast is that Life? \r\n\r\nAll Rocks are bounded by a square with opposite corners (0,0) and (1,1). The camera only sees this 1x1 area. One Martian per Rock. Martians travel the minimum distance from the 1x1 edge to the initial rock position and from the final rock position to the edge to hide at velocity V. While moving a rock Marty's velocity reduces to V/2. An unmoved rock allows Marty to stay on the sideline. Note, the camera software does not track specific rocks, so an unmoved rock in Pict1 may be item 1 and this same rock may be item 4 in the second picture. Multiple rocks may occupy the same location in a picture.  \r\n\r\nReturn the Minimum Martian Speed to transition from the initial Rock set to the Final rock set. \r\n\r\n\r\n*Input: [Rock_locations_Pict1_Pict2,Time between pictures ]*\r\n\r\n*Output: [Minimum Martian Speed]*; to 2 decimal places;\r\n\r\n*Scoring: Cumulative Time ( msec )*\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pranks.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: [0.3 0.6;0.4 0.5;0.5 0.5;0.95 0.2;0.6 0.5;0.9 0.4;0.5 0.5; 0.3 0.6], 3.0*\r\n\r\nEssentially, 4 rocks in two pictures with a time between pictures of 3 seconds\r\n\r\n*Output: 0.37* is quite obvious, not in the least \r\n \r\nThis answer comes by moving [I1 F4; I2 F3; I3 F1; I4 F2] with rows two and three  being of equal maximum effective distance of 1.1. My \"effective distance\" for I2 F3 is .4 + (.1)*2 + .5, where .1 is hypot(I2,F3) and multiply by 2 for speed reduction. This 1.1/3 rounds to 0.37.\r\n\r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pranks.zhencao.cpp.txt The Winner's Pranks solution\u003e.  This solution is much tighter than my first method thus I am scoring by time.  Hopefully someone can champion Matlab and produce a succinct and worthy solution. The winner solved this in 22 minutes and second place took a leisurely 65 minutes. Time Started when the page was opened.\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is to solve Question C, Martian Pranks, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eRocks are moving between Rover pictures. This proves Life on Mars, but how Fast is that Life?\u003c/p\u003e\u003cp\u003eAll Rocks are bounded by a square with opposite corners (0,0) and (1,1). The camera only sees this 1x1 area. One Martian per Rock. Martians travel the minimum distance from the 1x1 edge to the initial rock position and from the final rock position to the edge to hide at velocity V. While moving a rock Marty's velocity reduces to V/2. An unmoved rock allows Marty to stay on the sideline. Note, the camera software does not track specific rocks, so an unmoved rock in Pict1 may be item 1 and this same rock may be item 4 in the second picture. Multiple rocks may occupy the same location in a picture.\u003c/p\u003e\u003cp\u003eReturn the Minimum Martian Speed to transition from the initial Rock set to the Final rock set.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [Rock_locations_Pict1_Pict2,Time between pictures ]\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [Minimum Martian Speed]\u003c/b\u003e; to 2 decimal places;\u003c/p\u003e\u003cp\u003e\u003cb\u003eScoring: Cumulative Time ( msec )\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [0.3 0.6;0.4 0.5;0.5 0.5;0.95 0.2;0.6 0.5;0.9 0.4;0.5 0.5; 0.3 0.6], 3.0\u003c/b\u003e\u003c/p\u003e\u003cp\u003eEssentially, 4 rocks in two pictures with a time between pictures of 3 seconds\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: 0.37\u003c/b\u003e is quite obvious, not in the least\u003c/p\u003e\u003cp\u003eThis answer comes by moving [I1 F4; I2 F3; I3 F1; I4 F2] with rows two and three  being of equal maximum effective distance of 1.1. My \"effective distance\" for I2 F3 is .4 + (.1)*2 + .5, where .1 is hypot(I2,F3) and multiply by 2 for speed reduction. This 1.1/3 rounds to 0.37.\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.zhencao.cpp.txt\"\u003eThe Winner's Pranks solution\u003c/a\u003e.  This solution is much tighter than my first method thus I am scoring by time.  Hopefully someone can champion Matlab and produce a succinct and worthy solution. The winner solved this in 22 minutes and second place took a leisurely 65 minutes. Time Started when the page was opened.\u003c/p\u003e","function_template":"function [v]=Pranks(R,t)\r\n  v=0;\r\nend","test_suite":"feval(@assignin,'caller','score',4000);\r\n%%\r\ntic\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pranks.in.txt','pranks.in.txt')\r\ntoc\r\n%%\r\n fid=fopen('pranks.in.txt','r');\r\n v_expect=[.37 .26 1.11 .02 .89 .79 .01 .17 .37 1.05 .28 .04 .02 .09 .14 .49 .71 .06 .01];\r\n \r\n qty=fscanf(fid,'%i',1);\r\n\r\n t1=0;\r\n for q=1:qty %qty\r\n  n = fscanf(fid,'%f %f \\n',2)'; % num_rocks, time\r\n  t=n(2);\r\n  \r\n  A=zeros(2*n(1),2); % Format is rows, columns\r\n  for i=1:2*n(1)\r\n   r = fscanf(fid,'%f %f \\n',2)';\r\n   A(i,:) = r;\r\n  end\r\n \r\n \r\n  tic\r\n  ta=clock;\r\n   [v]=Pranks(A,t) ;\r\n  t1=t1+etime(clock,ta)*1000; % Time in msec\r\n   \r\nfprintf('%2i  vel %.2f  Sum Time %.0f \\n',q,v,t1)\r\n  \r\n  assert(isequal(v,v_expect(q)));\r\n   \r\n end\r\n \r\n fprintf('Processing Complete\\n')\r\n fclose(fid);\r\n\r\n\r\nt2=min(4000,t1);\r\nfprintf('Actual Time = %.0f msec\\n',t1)\r\n\r\nfeval(@assignin,'caller','score',floor(t2));","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":3097,"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":"2012-12-10T00:08:26.000Z","updated_at":"2012-12-10T01:48:14.000Z","published_at":"2012-12-10T01:48:14.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\u003eThis Challenge is to solve Question C, Martian Pranks, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRocks are moving between Rover pictures. This proves Life on Mars, but how Fast is that Life?\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\u003eAll Rocks are bounded by a square with opposite corners (0,0) and (1,1). The camera only sees this 1x1 area. One Martian per Rock. Martians travel the minimum distance from the 1x1 edge to the initial rock position and from the final rock position to the edge to hide at velocity V. While moving a rock Marty's velocity reduces to V/2. An unmoved rock allows Marty to stay on the sideline. Note, the camera software does not track specific rocks, so an unmoved rock in Pict1 may be item 1 and this same rock may be item 4 in the second picture. Multiple rocks may occupy the same location in a picture.\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\u003eReturn the Minimum Martian Speed to transition from the initial Rock set to the Final rock set.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [Rock_locations_Pict1_Pict2,Time between pictures ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [Minimum Martian Speed]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; to 2 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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eScoring: Cumulative Time ( msec )\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [0.3 0.6;0.4 0.5;0.5 0.5;0.95 0.2;0.6 0.5;0.9 0.4;0.5 0.5; 0.3 0.6], 3.0\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\u003eEssentially, 4 rocks in two pictures with a time between pictures of 3 seconds\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: 0.37\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is quite obvious, not in the least\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis answer comes by moving [I1 F4; I2 F3; I3 F1; I4 F2] with rows two and three being of equal maximum effective distance of 1.1. My \\\"effective distance\\\" for I2 F3 is .4 + (.1)*2 + .5, where .1 is hypot(I2,F3) and multiply by 2 for speed reduction. This 1.1/3 rounds to 0.37.\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pranks.zhencao.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eThe Winner's Pranks solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. This solution is much tighter than my first method thus I am scoring by time. Hopefully someone can champion Matlab and produce a succinct and worthy solution. The winner solved this in 22 minutes and second place took a leisurely 65 minutes. Time Started when the page was opened.\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":1122,"title":"USC Fall 2012 ACM: Rover Maze","description":"This Challenge is to solve Question F, Martian Pits, of the \u003chttp://contest.usc.edu/index.php/Fall12/Home USC ACM Fall 2012 Contest\u003e.\r\n\r\nThe task is to determine the minimum time for the Rover to drive from its current position to a Goal location. The Rover must STOP on the Goal location. Commands are processed at 1 Cmd per sec. Rover must stay on array.\r\n\r\nThis is an intriguing Maze problem that incorporates turn penalties, variable speed forward, and a fixed reverse speed.\r\n\r\n  Initial conditions are Rover Stopped and Facing +Y.\r\n  Commands are processed at 1 second intervals\r\n  \r\n  Commands and their attributes:\r\n  FORWARD: Starts rolling forward at 1 cm/s\r\n  BACKWARDS: Roll backwards at 1 cm/s\r\n  FASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\n  SLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\n  STOP: Halts rover movement\r\n  RIGHT: Turn rover 90 degrees to the right\r\n  LEFT: Turn the rover 90 degrees to the left\r\n  NOOP: No change in anything \r\n\r\n\r\n  Commands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\r\n  Commands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\r\n\r\n*Input: [Char array]* \".\" is Flat ground, \"P\" Pit, \"R\" Rover start location, \"D\" is Destination.  Matrix max dim 50, min 1. \r\n\r\n*Output: [T]*; Drive Time to destination; -1 if not possible\r\n\r\n*Scoring: Time (msec)*\r\n\r\n\r\nThe full \u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pits.in.txt USC data file\u003e\r\n\r\n*Example:*\r\n\r\n*Input: [A]*\r\n\r\n  ...................D\r\n  .P......P.P.........\r\n  .P...PPPP.P.........\r\n  .P...P....P.........\r\n  .P...P.PPPP.........\r\n  .P.PPP.P............\r\n  .P.P...P............\r\n  .PPP.PPPPPPPPPPPPPPP\r\n  ....R...............\r\n  PPPPPPPPPPPPPPPPPPPP\r\n\r\n*Output: [19]* as the best path is L, Fwd, Faster, Slower, Stop to (9,1). The cmds to reach (1,1) are R, Fwd, Faster, Faster, Slower, Stop. Cmds to optimally reach (1,20) are R, Fwd, Faster, Faster, Faster, Faster, Slower, Stop. \r\n\r\nOnce again my code is large thus the contest will be scored based on Processing Time.\r\n\r\n*Hints:* One Speed-Up method is to do an initial Start/Finish connectivity check.\r\n \r\n\r\n\u003chttp://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pits.yucheng.cpp.txt Martian Pits C solution\u003e.  Time to Solve: 40 minutes. Only three solved this puzzle during the contest. Start.","description_html":"\u003cp\u003eThis Challenge is to solve Question F, Martian Pits, of the \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home\"\u003eUSC ACM Fall 2012 Contest\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eThe task is to determine the minimum time for the Rover to drive from its current position to a Goal location. The Rover must STOP on the Goal location. Commands are processed at 1 Cmd per sec. Rover must stay on array.\u003c/p\u003e\u003cp\u003eThis is an intriguing Maze problem that incorporates turn penalties, variable speed forward, and a fixed reverse speed.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInitial conditions are Rover Stopped and Facing +Y.\r\nCommands are processed at 1 second intervals\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands and their attributes:\r\nFORWARD: Starts rolling forward at 1 cm/s\r\nBACKWARDS: Roll backwards at 1 cm/s\r\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\r\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \"Stopped\"\r\nSTOP: Halts rover movement\r\nRIGHT: Turn rover 90 degrees to the right\r\nLEFT: Turn the rover 90 degrees to the left\r\nNOOP: No change in anything \r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eCommands FASTER and SLOWER only take effect if the rover is moving forward.\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eInput: [Char array]\u003c/b\u003e \".\" is Flat ground, \"P\" Pit, \"R\" Rover start location, \"D\" is Destination.  Matrix max dim 50, min 1.\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput: [T]\u003c/b\u003e; Drive Time to destination; -1 if not possible\u003c/p\u003e\u003cp\u003e\u003cb\u003eScoring: Time (msec)\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThe full \u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.in.txt\"\u003eUSC data file\u003c/a\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput: [A]\u003c/b\u003e\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e...................D\r\n.P......P.P.........\r\n.P...PPPP.P.........\r\n.P...P....P.........\r\n.P...P.PPPP.........\r\n.P.PPP.P............\r\n.P.P...P............\r\n.PPP.PPPPPPPPPPPPPPP\r\n....R...............\r\nPPPPPPPPPPPPPPPPPPPP\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eOutput: [19]\u003c/b\u003e as the best path is L, Fwd, Faster, Slower, Stop to (9,1). The cmds to reach (1,1) are R, Fwd, Faster, Faster, Slower, Stop. Cmds to optimally reach (1,20) are R, Fwd, Faster, Faster, Faster, Faster, Slower, Stop.\u003c/p\u003e\u003cp\u003eOnce again my code is large thus the contest will be scored based on Processing Time.\u003c/p\u003e\u003cp\u003e\u003cb\u003eHints:\u003c/b\u003e One Speed-Up method is to do an initial Start/Finish connectivity check.\u003c/p\u003e\u003cp\u003e\u003ca href=\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.yucheng.cpp.txt\"\u003eMartian Pits C solution\u003c/a\u003e.  Time to Solve: 40 minutes. Only three solved this puzzle during the contest. Start.\u003c/p\u003e","function_template":"function t=Pits(A)\r\n  t=-1;\r\n\r\nend","test_suite":"feval(@assignin,'caller','score',1000);\r\n%%\r\nurlwrite('http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026upname=pits.in.txt','pits.in.txt');\r\n%%\r\n fid=fopen('pits.in.txt','r');\r\n t_expect=[19 2 2 3 -1 7 14 23 401 200 42 -1 27 -1];\r\n \r\n t1=0;\r\n qty=fscanf(fid,'%i',1);\r\nfor q=1:qty %qty\r\n  n = fscanf(fid,'%f %f\\n',2)'; % array size\r\n  A=zeros(n);\r\n  for i=1:n(1)\r\n   strv=fgetl(fid);\r\n   %A(i,:)=strv-'.';\r\n   A(i,:)=strv;\r\n  end\r\n\r\n  ta=clock;\r\n   [t]=Pits(char(A)) ;\r\n  t1=t1+etime(clock,ta)*1000; % Time in msec\r\n   \r\n  fprintf('%2i  Cmds %3.0f  Sum Time %.0f \\n',q,t,t1)\r\n\r\n  %isequal(t,t_expect(q))\r\n\r\n  assert(isequal(t,t_expect(q)));\r\n\r\nend % q\r\n\r\nt2=min(1000,t1);\r\nfprintf('Actual Time = %.1f msec\\n',t1)\r\nfeval(@assignin,'caller','score',floor(t2));","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"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":"2012-12-14T01:14:38.000Z","updated_at":"2012-12-14T02:24:14.000Z","published_at":"2012-12-14T02:24:14.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\u003eThis Challenge is to solve Question F, Martian Pits, of 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=\\\"http://contest.usc.edu/index.php/Fall12/Home\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC ACM Fall 2012 Contest\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe task is to determine the minimum time for the Rover to drive from its current position to a Goal location. The Rover must STOP on the Goal location. Commands are processed at 1 Cmd per sec. Rover must stay on array.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is an intriguing Maze problem that incorporates turn penalties, variable speed forward, and a fixed reverse speed.\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[Initial conditions are Rover Stopped and Facing +Y.\\nCommands are processed at 1 second intervals\\n\\nCommands and their attributes:\\nFORWARD: Starts rolling forward at 1 cm/s\\nBACKWARDS: Roll backwards at 1 cm/s\\nFASTER: Increase forward speed by 1 cm/s up to 5 cm/s\\nSLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is \\\"Stopped\\\"\\nSTOP: Halts rover movement\\nRIGHT: Turn rover 90 degrees to the right\\nLEFT: Turn the rover 90 degrees to the left\\nNOOP: No change in anything \\n\\nCommands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.\\n\\nCommands FASTER and SLOWER only take effect if the rover is moving forward.]]\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [Char array]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \\\".\\\" is Flat ground, \\\"P\\\" Pit, \\\"R\\\" Rover start location, \\\"D\\\" is Destination. Matrix max dim 50, min 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [T]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e; Drive Time to destination; -1 if not possible\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eScoring: Time (msec)\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 full\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.in.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eUSC data file\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput: [A]\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[...................D\\n.P......P.P.........\\n.P...PPPP.P.........\\n.P...P....P.........\\n.P...P.PPPP.........\\n.P.PPP.P............\\n.P.P...P............\\n.PPP.PPPPPPPPPPPPPPP\\n....R...............\\nPPPPPPPPPPPPPPPPPPPP]]\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput: [19]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as the best path is L, Fwd, Faster, Slower, Stop to (9,1). The cmds to reach (1,1) are R, Fwd, Faster, Faster, Slower, Stop. Cmds to optimally reach (1,20) are R, Fwd, Faster, Faster, Faster, Faster, Slower, Stop.\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\u003eOnce again my code is large thus the contest will be scored based on Processing Time.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHints:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e One Speed-Up method is to do an initial Start/Finish connectivity check.\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:hyperlink w:docLocation=\\\"http://contest.usc.edu/index.php/Fall12/Home?action=download\u0026amp;upname=pits.yucheng.cpp.txt\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMartian Pits C solution\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Time to Solve: 40 minutes. Only three solved this puzzle during the contest. Start.\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:\"acm\"","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:\"acm\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"acm\"","","\"","acm","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f460ccc21e0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f460ccc20a0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f460ccc1380\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f460ccc2460\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f460ccc23c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f460ccc2320\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f460ccc2280\u003e":"tag:\"acm\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f460ccc2280\u003e":"tag:\"acm\""},"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:\"acm\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"acm\"","","\"","acm","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f460ccc21e0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f460ccc20a0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f460ccc1380\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f460ccc2460\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f460ccc23c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f460ccc2320\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f460ccc2280\u003e":"tag:\"acm\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f460ccc2280\u003e":"tag:\"acm\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":1098,"difficulty_rating":"easy"},{"id":1457,"difficulty_rating":"medium"},{"id":1101,"difficulty_rating":"medium"},{"id":1102,"difficulty_rating":"medium"},{"id":1109,"difficulty_rating":"medium"},{"id":1115,"difficulty_rating":"medium"},{"id":1110,"difficulty_rating":"unrated"},{"id":1122,"difficulty_rating":"unrated"}]}}