{"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":2312,"title":"How many solutions has this problem?","description":"Guess, predict or calculate :-)\r\n\r\n(You will be scored by the accuracy).\r\n\r\n\r\n\r\n\r\nUpdate: \u003chttp://www.mathworks.co.uk/matlabcentral/about/trendy/ TRENDY\u003e \u003chttp://www.mathworks.co.uk/matlabcentral/trendy/Tutorial/urlfilter.html is\u003e here!","description_html":"\u003cp\u003eGuess, predict or calculate :-)\u003c/p\u003e\u003cp\u003e(You will be scored by the accuracy).\u003c/p\u003e\u003cp\u003eUpdate: \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/about/trendy/\"\u003eTRENDY\u003c/a\u003e \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/trendy/Tutorial/urlfilter.html\"\u003eis\u003c/a\u003e here!\u003c/p\u003e","function_template":"function y = solutions(x)\r\n  y = 42;\r\nend","test_suite":"%%\r\n% please ''ignore'' this first test, this code is here to put function \r\n% urlfilter known from matlabcentral/trendy to the path for this problem\r\n% (method taken from Doug's Hull problem Steal, Share, or Catch)\r\nfh=fopen('urlfilter.m','wt');\r\nfprintf(fh, '%s \\n', 'function out = urlfilter(url, target, numNumbers, direction)') ;\r\nfprintf(fh, '%s \\n', '  if nargin \u003c 3, numNumbers = 1; end');\r\nfprintf(fh, '%s \\n', '  if nargin \u003c 4 direction = ''forward''; end');\r\nfprintf(fh, '%s \\n', '  % If url is not an actual URL, then treat it as a string');\r\nfprintf(fh, '%s \\n', '  if strcmp(url(1:4),''http''), textStr = urlread(url); else textStr = url; end');\r\nfprintf(fh, '%s \\n', '  % Handle special case where two numbers are given as part of a range');\r\nfprintf(fh, '%s \\n', '  %   Example: \"annual rainfall = 20-40 inches\"');\r\nfprintf(fh, '%s \\n', '  % Solution is a pre-processing step that replaces the dash with a space');\r\nfprintf(fh, '%s \\n', '  %   Example: \"annual rainfall = 20 40 inches\"');\r\nfprintf(fh, '%s \\n', '  textStr = regexprep(textStr,''(\\d+)-(\\d+)'',''$1 $2'');');\r\nfprintf(fh, '%s \\n', '  strIndex = strfind(textStr,target);');\r\nfprintf(fh, '%s \\n', '  if isempty(strIndex),');\r\nfprintf(fh, '%s \\n', '    error( ''trendy:urlfilter:TargetStringNotFound'', ...');\r\nfprintf(fh, '%s \\n', '          [''Target string '' target '' does not appear''])');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', '  % Start looking after the first appearance of the target');\r\nfprintf(fh, '%s \\n', '  if strcmp(direction,''forward'')');\r\nfprintf(fh, '%s \\n', '    strIndex = strIndex(1) + length(target);');\r\nfprintf(fh, '%s \\n', '  elseif strcmp(direction,''backward'')');\r\nfprintf(fh, '%s \\n', '    strIndex = strIndex(1) - 1;');\r\nfprintf(fh, '%s \\n', '  else');\r\nfprintf(fh, '%s \\n', '    error( ''trendy:urlfilter:InvalidDirectionFlag'', ...');\r\nfprintf(fh, '%s \\n', '           ''DIRECTION must be either ''''forward'''' or ''''backward''''.'' );');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', '  out = zeros(1,numNumbers);');\r\nfprintf(fh, '%s \\n', '  for i = 1:numNumbers');\r\nfprintf(fh, '%s \\n', '    [out(i),strIndex] = getNextNumber(textStr,strIndex,direction);');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', 'end');\r\nfprintf(fh, '%s \\n', '% =========================');\r\nfprintf(fh, '%s \\n', 'function [nextNumber,strIndex] = getNextNumber(textStr,strIndex,direction)');\r\nfprintf(fh, '%s \\n', '  % Use a state machine to sift through the HTML for numbers.');\r\nfprintf(fh, '%s \\n', '  if strcmp(direction,''forward'')');\r\nfprintf(fh, '%s \\n', '    openTagSymbol  = ''\u003c'';');\r\nfprintf(fh, '%s \\n', '    closeTagSymbol = ''\u003e'';');\r\nfprintf(fh, '%s \\n', '    moveIndexFcn   = @(x) x+1;');\r\nfprintf(fh, '%s \\n', '    concatenateFcn = @(a,b) [a b];');\r\nfprintf(fh, '%s \\n', '  else');\r\nfprintf(fh, '%s \\n', '    openTagSymbol  = ''\u003e'';');\r\nfprintf(fh, '%s \\n', '    closeTagSymbol = ''\u003c'';');\r\nfprintf(fh, '%s \\n', '    moveIndexFcn   = @(x) x-1;');\r\nfprintf(fh, '%s \\n', '    concatenateFcn = @(a,b) [b a];');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', '  urlStrLen = length(textStr);');\r\nfprintf(fh, '%s \\n', '  state = ''notnumber'';');\r\nfprintf(fh, '%s \\n', '  while true');\r\nfprintf(fh, '%s \\n', '    ch = textStr(strIndex);');\r\nfprintf(fh, '%s \\n', '    switch state');\r\nfprintf(fh, '%s \\n', '      case ''notnumber''');\r\nfprintf(fh, '%s \\n', '        if isDigitDotDashOrComma(ch)');\r\nfprintf(fh, '%s \\n', '          state = ''number'';');\r\nfprintf(fh, '%s \\n', '          numStr = ch;');\r\nfprintf(fh, '%s \\n', '        elseif (ch == openTagSymbol)');\r\nfprintf(fh, '%s \\n', '          state = ''tagbody'';');\r\nfprintf(fh, '%s \\n', '        end');\r\nfprintf(fh, '%s \\n', '      case ''tagbody''');\r\nfprintf(fh, '%s \\n', '        % Throw away anything inside the tag markup area');\r\nfprintf(fh, '%s \\n', '        if (ch == closeTagSymbol)');\r\nfprintf(fh, '%s \\n', '          state = ''notnumber'';');\r\nfprintf(fh, '%s \\n', '        end ');\r\nfprintf(fh, '%s \\n', '      case ''number''');\r\nfprintf(fh, '%s \\n', '        if isDigitDotDashOrComma(ch)');\r\nfprintf(fh, '%s \\n', '          numStr = concatenateFcn(numStr,ch);');\r\nfprintf(fh, '%s \\n', '        else');\r\nfprintf(fh, '%s \\n', '          % We are transitioning out of a number.');\r\nfprintf(fh, '%s \\n', '          % Note that STR2DOUBLE handles commas in the string.');\r\nfprintf(fh, '%s \\n', '          nextNumber = str2double(numStr);');\r\nfprintf(fh, '%s \\n', '          if ~isnan(nextNumber)');\r\nfprintf(fh, '%s \\n', '            % The number is valid. We''re all done.');\r\nfprintf(fh, '%s \\n', '            break');\r\nfprintf(fh, '%s \\n', '          else');\r\nfprintf(fh, '%s \\n', '            % The number is bogus. Throw it away and continue.');\r\nfprintf(fh, '%s \\n', '            if (ch == openTagSymbol), state = ''tagbody''; else state = ''notnumber''; end');\r\nfprintf(fh, '%s \\n', '          end');\r\nfprintf(fh, '%s \\n', '        end');\r\nfprintf(fh, '%s \\n', '      otherwise');\r\nfprintf(fh, '%s \\n', '        error( ''trendy:urlfilter:InvalidState'', ...');\r\nfprintf(fh, '%s \\n', '             [''Encountered unknown state '' state])');\r\nfprintf(fh, '%s \\n', '    end');\r\nfprintf(fh, '%s \\n', '    strIndex = moveIndexFcn(strIndex);');\r\nfprintf(fh, '%s \\n', '    if (strIndex == 0) || (strIndex \u003e urlStrLen)');\r\nfprintf(fh, '%s \\n', '      % We ran off the end of the string.');\r\nfprintf(fh, '%s \\n', '      disp(''End of file reached.'')');\r\nfprintf(fh, '%s \\n', '      break');\r\nfprintf(fh, '%s \\n', '    end');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', 'end');\r\nfprintf(fh, '%s \\n', '% ==================');\r\nfprintf(fh, '%s \\n', 'function tf = isDigitDotDashOrComma(ch)');\r\nfprintf(fh, '%s \\n', '  tf = ((ch \u003e= ''0'') \u0026\u0026 (ch \u003c= ''9'')) || ...');\r\nfprintf(fh, '%s \\n', '          (ch == ''.'') || (ch == ''-'') || (ch == '','');');\r\nfprintf(fh, '%s \\n', 'end');\r\nfclose(fh);\r\n%%\r\nrehash path\r\n%%\r\ny=solutions();\r\nassert(isequal(mod(y,1),0))\r\n%%\r\ny=solutions();\r\nassert(y\u003e0);\r\n%%\r\ny=solutions();\r\n% yes, yes solution hidden in the test suite... try to code adifferent one! :-)\r\nurl='http://www.mathworks.co.uk/matlabcentral/cody/problems/2312'\r\ny_correct=max([0 cellfun(@(S)str2num(cell2mat(S)),regexp(urlread(url),'\u003cspan class=\"solution_statistic\"\u003e(\\d*)\u003c/span\u003e\u003cspan class=\"text\"\u003e Solutions\u003c/span\u003e','tokens'))]) + 1; % don't forget your solution\r\nt = mtree('solutions.m','-file');\r\nsize = ceil(length(t.nodesize)/13);\r\nfeval(@assignin,'caller','score',abs(y-y_correct)+size);\r\n% (... and solutions will be rescored from time to time :-D)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":"2014-05-12T12:02:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-05-08T08:33:51.000Z","updated_at":"2026-02-18T14:23:20.000Z","published_at":"2014-05-08T09:06:48.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\u003eGuess, predict or calculate :-)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(You will be scored by the accuracy).\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eUpdate:\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.co.uk/matlabcentral/about/trendy/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTRENDY\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\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/trendy/Tutorial/urlfilter.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eis\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e here!\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":2424,"title":"Latest Question On Cody","description":"Get the problem number of the latest submitted Problem on Cody. Copying the test suite code might not help.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; \"\u003e\u003cspan style=\"\"\u003eGet the problem number of the latest submitted Problem on Cody. Copying the test suite code might not help.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = numProb()\r\n\r\nend","test_suite":"%%\r\ntic\r\nurl = 'https://www.mathworks.com/matlabcentral/cody/problems?term=\u0026sort=created+desc';\r\nhtml = urlread(url);\r\npattern = ['\"problem_[0-9]+\"'];\r\nc = regexp(html,pattern,'match');\r\nq = c{1};\r\nn = str2num(q(isstrprop(q,'digit')));\r\nt_act = toc;\r\n\r\n\r\ntic\r\nn1 = numProb();\r\nt_1 = toc;\r\n\r\ntest_result = isequal(n1,n);\r\nif test_result\r\n    disp(\"The solution works.\")\r\nelse\r\n    assert(false);\r\nend\r\nassert(t_1\u003c=(t_act*0.95));\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":17203,"edited_by":26769,"edited_at":"2022-04-12T12:44:32.000Z","deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":"2022-04-12T12:44:32.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-07-14T08:42:16.000Z","updated_at":"2025-12-08T23:36:16.000Z","published_at":"2014-07-14T08:42:16.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGet the problem number of the latest submitted Problem on Cody. Copying the test suite code might not help.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":699,"title":"Reading Web Binary Files (jpg,pdf,tiff,png)","description":"The Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\r\n\r\n.\r\n\r\nAccessing files on the web provide multiple challenges due to the data structures being text or binary.\r\n\r\nThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\r\n\r\n\r\n\r\nInput:\r\n\r\nfname 'http://some valid location/file.pdf'\r\n\r\nn      The byte for which the value is being requested.\r\n\r\nOutput: Value of the byte, an integer ranging from 0 to 255\r\n\r\n.\r\n\r\n\r\nA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\r\n\r\nA urlreadbin can be readily created to directly push the file to an array.","description_html":"\u003cp\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/p\u003e\u003cp\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\u003c/p\u003e\u003cp\u003eInput:\u003c/p\u003e\u003cp\u003efname 'http://some valid location/file.pdf'\u003c/p\u003e\u003cp\u003en      The byte for which the value is being requested.\u003c/p\u003e\u003cp\u003eOutput: Value of the byte, an integer ranging from 0 to 255\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/p\u003e\u003cp\u003eA urlreadbin can be readily created to directly push the file to an array.\u003c/p\u003e","function_template":"function y = access_web_pdf(fname,n)\r\n  y = 0;\r\nend","test_suite":"%%\r\n% Cody External accessibility\r\n\r\n% This file may need to change in the future\r\nin_f='http://www.pvplc.org/_volunteer/docs/PVPLC%20Trail%20Crew%20Training%20Jan-Jun%202012.pdf';\r\n\r\nout_f='PVPLC.pdf';\r\n\r\nurlwrite(in_f,out_f);\r\n\r\nfid=fopen(out_f);\r\nurlwrite_out=fread(fid,128,'*uint8'); \r\n% Display Correct Binary Data\r\nurlwrite_out(1:16)'\r\n\r\n\r\nblock=urlread(in_f);\r\n% Display invalid binary data\r\nurlread_out=block(1:16)-char(0)\r\n% unicode urlread conversion affects bytes 12 thru 15\r\n\r\nn=12\r\nbyte_val = access_web_pdf(in_f,n)\r\n\r\nbyte_correct=181;\r\n\r\nassert(isequal(byte_val,byte_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-05-18T04:26:21.000Z","updated_at":"2012-05-21T05:35:07.000Z","published_at":"2012-05-21T05:35:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003efname 'http://some valid location/file.pdf'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en The byte for which the value is being requested.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: Value of the byte, an integer ranging from 0 to 255\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA urlreadbin can be readily created to directly push the file to an array.\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":877,"title":"What is Title of Cody Challenge 42?","description":"Given a Cody Challenge number return its Title.\r\n\r\n*Input:* Cody Challenge Number\r\n\r\n*Output:* Title of the Cody Challenge\r\n\r\n  1 'Times 2 - START HERE'  \r\n  2 'Make the vector [1 2 3 4 5 6 7 8 9 10]' \r\n110 'Make an N-dimensional Multiplication Table'\r\n808 'Hamming Weight - Fast'  \r\n\r\n\r\nFor my methods this was non-trivial due to hyperlink issues.\r\n\r\n Warning:What \"you\" may see is not what you \"get\"\r\n Can anyone \"get\" the title to challenge 4?\r\n My method faces many blocked challenge numbers.\r\n\r\n(I retain the right to add cases if hard coded answers are invoked and become the leading solution size)","description_html":"\u003cp\u003eGiven a Cody Challenge number return its Title.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e Cody Challenge Number\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Title of the Cody Challenge\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 'Times 2 - START HERE'  \r\n2 'Make the vector [1 2 3 4 5 6 7 8 9 10]' \r\n110 'Make an N-dimensional Multiplication Table'\r\n808 'Hamming Weight - Fast'  \r\n\u003c/pre\u003e\u003cp\u003eFor my methods this was non-trivial due to hyperlink issues.\u003c/p\u003e\u003cpre\u003e Warning:What \"you\" may see is not what you \"get\"\r\n Can anyone \"get\" the title to challenge 4?\r\n My method faces many blocked challenge numbers.\u003c/pre\u003e\u003cp\u003e(I retain the right to add cases if hard coded answers are invoked and become the leading solution size)\u003c/p\u003e","function_template":"function Title = Cody_Title(n)\r\n  Title='Good Luck';\r\nend","test_suite":"%%\r\nn = 1;\r\nTitle_correct = 'Times 2 - START HERE';\r\nassert(strcmp(Cody_Title(n),Title_correct))\r\n%%\r\nn = 2;\r\nTitle_correct = 'Make the vector [1 2 3 4 5 6 7 8 9 10]';\r\nassert(strcmp(Cody_Title(n),Title_correct))\r\n%%\r\nn = 110;\r\nTitle_correct = 'Make an N-dimensional Multiplication Table';\r\n% This problem hurts my head\r\nassert(strcmp(Cody_Title(n),Title_correct))\r\n%%\r\nn = 808;\r\nTitle_correct = 'Hamming Weight - Fast';\r\nassert(strcmp(Cody_Title(n),Title_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":3,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":32,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-08-04T14:40:09.000Z","updated_at":"2025-12-27T16:14:18.000Z","published_at":"2012-08-04T16:25:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a Cody Challenge number return its Title.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003cw:r\u003e\u003cw:t\u003e Cody Challenge Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw: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 Title of the Cody Challenge\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 'Times 2 - START HERE'  \\n2 'Make the vector [1 2 3 4 5 6 7 8 9 10]' \\n110 'Make an N-dimensional Multiplication Table'\\n808 'Hamming Weight - Fast']]\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\u003eFor my methods this was non-trivial due to hyperlink issues.\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[ Warning:What \\\"you\\\" may see is not what you \\\"get\\\"\\n Can anyone \\\"get\\\" the title to challenge 4?\\n My method faces many blocked challenge numbers.]]\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\u003e(I retain the right to add cases if hard coded answers are invoked and become the leading solution size)\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":779,"title":"Read a Text file from a URL and create an {N x 1}  Cell Array","description":"Given a URL string for a text file, read the text file and store the contents into a cell array.\r\n\r\nThe text file will have contiguous characters on different lines.\r\n\r\n*Inputs:*\r\n\r\nURL/File string  (eg 'http://www.toobigforemail.com/cryptkeeper.toobig?npp=xgz8xdyx') (This is close but not a valid link)\r\n\r\nThis is a link to a text file.\r\n\r\nNote: I tried to use my Google WebPage but it is an \"https\".\r\n\r\nurlread for 2012a does not like https sites.  (2012b???)\r\n\r\n*Typical Text File:*\r\n\r\nread2cell.txt\r\n\r\nabcd\r\n\r\nwxyz\r\n\r\n*Output:*\r\n\r\n{2x1 cell}\r\n\r\n'abcd'\r\n\r\n'wxyz'\r\n \r\n\r\nThis is intended as an introductory function usage.\r\n\r\nFollow up will be, \"Is it a valid scrabble word?\", once I find that scrabble dictionary.","description_html":"\u003cp\u003eGiven a URL string for a text file, read the text file and store the contents into a cell array.\u003c/p\u003e\u003cp\u003eThe text file will have contiguous characters on different lines.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInputs:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eURL/File string  (eg 'http://www.toobigforemail.com/cryptkeeper.toobig?npp=xgz8xdyx') (This is close but not a valid link)\u003c/p\u003e\u003cp\u003eThis is a link to a text file.\u003c/p\u003e\u003cp\u003eNote: I tried to use my Google WebPage but it is an \"https\".\u003c/p\u003e\u003cp\u003eurlread for 2012a does not like https sites.  (2012b???)\u003c/p\u003e\u003cp\u003e\u003cb\u003eTypical Text File:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eread2cell.txt\u003c/p\u003e\u003cp\u003eabcd\u003c/p\u003e\u003cp\u003ewxyz\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e{2x1 cell}\u003c/p\u003e\u003cp\u003e'abcd'\u003c/p\u003e\u003cp\u003e'wxyz'\u003c/p\u003e\u003cp\u003eThis is intended as an introductory function usage.\u003c/p\u003e\u003cp\u003eFollow up will be, \"Is it a valid scrabble word?\", once I find that scrabble dictionary.\u003c/p\u003e","function_template":"function dict = read_url_txtfn2cellarray(url_fname)\r\n  dict = {};\r\nend","test_suite":"%%\r\n%read2cell.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyefee\u00266cq_kc2=yae1ad\u00266cq_konmpb=xgz8yxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd';'wxyz';'mn  ';'pqr ']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))\r\n%%\r\n%read2cell02.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyeffg\u00266cq_kc2=yae1af\u00266cq_konmpb=8x1eyxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd';'wxyz']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))\r\n%%\r\n%read2cell03.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyeffg\u00266cq_kc2=yae1dg\u00266cq_konmpb=8x1eyxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd';'wxyz';'123 ']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))\r\n%%\r\n%read2cell04.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyeffg\u00266cq_kc2=yae1d1\u00266cq_konmpb=y88ayxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd ';'wxyz ';'123  ';'mnopq';'hij  ']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))","published":true,"deleted":false,"likes_count":0,"comments_count":5,"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-06-21T04:02:33.000Z","updated_at":"2012-06-22T02:54:47.000Z","published_at":"2012-06-22T02:54:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a URL string for a text file, read the text file and store the contents into a cell 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\u003eThe text file will have contiguous characters on different lines.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eInputs:\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eURL/File string (eg 'http://www.toobigforemail.com/cryptkeeper.toobig?npp=xgz8xdyx') (This is close but not a valid link)\u003c/w:t\u003e\u003c/w:r\u003e\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 a link to a text file.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eNote: I tried to use my Google WebPage but it is an \\\"https\\\".\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eurlread for 2012a does not like https sites. (2012b???)\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eTypical Text File:\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eread2cell.txt\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eabcd\u003c/w:t\u003e\u003c/w:r\u003e\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\u003ewxyz\u003c/w:t\u003e\u003c/w:r\u003e\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\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e{2x1 cell}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'abcd'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'wxyz'\u003c/w:t\u003e\u003c/w:r\u003e\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 intended as an introductory function usage.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eFollow up will be, \\\"Is it a valid scrabble word?\\\", once I find that scrabble dictionary.\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":1949,"title":"Get top 5 Cody Player Emails Automatically","description":"Yes, this is a little scary and also entirely possible to do in MATLAB, so let's do it!\r\n\r\nLooking at the list of the players \u003chttp://www.mathworks.com/matlabcentral/cody/players\u003e automatically sorts them in order according to rank. For times sake, let's say we only want to get the emails from the first 5 people. This is relatively easy to do by hand, just click on the persons name, click on \"View Profile Information\" and you have the email but if you wanted to do say the first 1,000 people instead, that would be not very fun to do by hand. \r\n\r\nFor this program, let's say we want the top 5 profiles that give a \"real\" email address (not a contact form) to be in a cell array. This means that if one of the top 5 people have removed their email address, your returned cell array will have less than 5 emails in it. \r\n\r\nIf you are not sure where to start, check out the urlread command, it allows you to put the web page source code into a string. From there, you are able to parse through that to get the URLs for the top 5 players web profile. From there, look for a \"mailto:\" and if it is there, the email address is immediately following it. If the string \"mailto:\" does not exist, there is no email address on that webpage. Put the emails in a cell array when you find them and you are good to go!\r\n\r\nAs an example, I have poorly written MATLAB code that works in the test case since I want the test case to always be accurate. 98% of the execution time is spent reading the webpages, and at least on my computer, that takes quite a while to do (about 2.5 seconds per profile page).\r\n\r\n*I am definitely not collecting emails for anything, and you should not either! This is designed solely as a learning example and should in no way be used for anything unethical. All information obtained here is easily obtained by anyone in the world who knows how to program.*\r\n\r\n*If this scares you and you want to remove your email address from your profile, it's easy. All you have to do is click \"My Community Profile\" (underneath the search bar at very top of screen) and then edit your preferences to not display your email address.* ","description_html":"\u003cp\u003eYes, this is a little scary and also entirely possible to do in MATLAB, so let's do it!\u003c/p\u003e\u003cp\u003eLooking at the list of the players \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/players\"\u003ehttp://www.mathworks.com/matlabcentral/cody/players\u003c/a\u003e automatically sorts them in order according to rank. For times sake, let's say we only want to get the emails from the first 5 people. This is relatively easy to do by hand, just click on the persons name, click on \"View Profile Information\" and you have the email but if you wanted to do say the first 1,000 people instead, that would be not very fun to do by hand.\u003c/p\u003e\u003cp\u003eFor this program, let's say we want the top 5 profiles that give a \"real\" email address (not a contact form) to be in a cell array. This means that if one of the top 5 people have removed their email address, your returned cell array will have less than 5 emails in it.\u003c/p\u003e\u003cp\u003eIf you are not sure where to start, check out the urlread command, it allows you to put the web page source code into a string. From there, you are able to parse through that to get the URLs for the top 5 players web profile. From there, look for a \"mailto:\" and if it is there, the email address is immediately following it. If the string \"mailto:\" does not exist, there is no email address on that webpage. Put the emails in a cell array when you find them and you are good to go!\u003c/p\u003e\u003cp\u003eAs an example, I have poorly written MATLAB code that works in the test case since I want the test case to always be accurate. 98% of the execution time is spent reading the webpages, and at least on my computer, that takes quite a while to do (about 2.5 seconds per profile page).\u003c/p\u003e\u003cp\u003e\u003cb\u003eI am definitely not collecting emails for anything, and you should not either! This is designed solely as a learning example and should in no way be used for anything unethical. All information obtained here is easily obtained by anyone in the world who knows how to program.\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eIf this scares you and you want to remove your email address from your profile, it's easy. All you have to do is click \"My Community Profile\" (underneath the search bar at very top of screen) and then edit your preferences to not display your email address.\u003c/b\u003e\u003c/p\u003e","function_template":"function emails = getCodyEmails()\r\n  emails = {};\r\nend","test_suite":"%%\r\n% My code is below, it's used to generate the expected result.\r\n\r\n%Read in the player page\r\nplayerPage=urlread('http://www.mathworks.com/matlabcentral/cody/players');\r\n\r\n%Find where the web address for each profile starts\r\nstartIdx=strfind(playerPage,'\u003cdiv class=\"grid_53 push_3\"\u003e')+104; \r\n\r\n%Initialize output array\r\nemails={};\r\n\r\n%Get top 5 only\r\nfor i=1:5\r\n    % Get the profile page link\r\n   tempStr=playerPage(startIdx(i):startIdx(i)+100);\r\n   quoteIdx=strfind(tempStr,'\"')-1;\r\n   profilePageLink=['http://www.mathworks.com' tempStr(1:quoteIdx(1))];\r\n   \r\n   profilePage=urlread(profilePageLink);\r\n   % Try and find mailto link\r\n   tStartIdx=strfind(profilePage,'mailto');\r\n   \r\n   %If you could find it\r\n   if ~isempty(tStartIdx)\r\n       % Get the email\r\n       tEndIdx=strfind(profilePage(tStartIdx:tStartIdx+100),'\"')+tStartIdx;\r\n       \r\n       % Add it to our cell array\r\n       emails{length(emails)+1}=profilePage(tStartIdx+7:tEndIdx-2);\r\n   end\r\n    \r\nend\r\n\r\n\r\ntic\r\nyourResponse=getCodyEmails()\r\ntimeElapsed=toc\r\n\r\n\r\nassert(isequal(yourResponse,emails))\r\nassert(isequal(1,timeElapsed\u003e3))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":3743,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-10-20T05:40:10.000Z","updated_at":"2025-07-31T17:14:24.000Z","published_at":"2013-10-20T05:40:10.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\u003eYes, this is a little scary and also entirely possible to do in MATLAB, so let's do it!\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eLooking at the list of the players\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/players\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.mathworks.com/matlabcentral/cody/players\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e automatically sorts them in order according to rank. For times sake, let's say we only want to get the emails from the first 5 people. This is relatively easy to do by hand, just click on the persons name, click on \\\"View Profile Information\\\" and you have the email but if you wanted to do say the first 1,000 people instead, that would be not very fun to do by hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this program, let's say we want the top 5 profiles that give a \\\"real\\\" email address (not a contact form) to be in a cell array. This means that if one of the top 5 people have removed their email address, your returned cell array will have less than 5 emails in it.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eIf you are not sure where to start, check out the urlread command, it allows you to put the web page source code into a string. From there, you are able to parse through that to get the URLs for the top 5 players web profile. From there, look for a \\\"mailto:\\\" and if it is there, the email address is immediately following it. If the string \\\"mailto:\\\" does not exist, there is no email address on that webpage. Put the emails in a cell array when you find them and you are good to go!\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eAs an example, I have poorly written MATLAB code that works in the test case since I want the test case to always be accurate. 98% of the execution time is spent reading the webpages, and at least on my computer, that takes quite a while to do (about 2.5 seconds per profile page).\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eI am definitely not collecting emails for anything, and you should not either! This is designed solely as a learning example and should in no way be used for anything unethical. All information obtained here is easily obtained by anyone in the world who knows how to program.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eIf this scares you and you want to remove your email address from your profile, it's easy. All you have to do is click \\\"My Community Profile\\\" (underneath the search bar at very top of screen) and then edit your preferences to not display your email address.\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":2312,"title":"How many solutions has this problem?","description":"Guess, predict or calculate :-)\r\n\r\n(You will be scored by the accuracy).\r\n\r\n\r\n\r\n\r\nUpdate: \u003chttp://www.mathworks.co.uk/matlabcentral/about/trendy/ TRENDY\u003e \u003chttp://www.mathworks.co.uk/matlabcentral/trendy/Tutorial/urlfilter.html is\u003e here!","description_html":"\u003cp\u003eGuess, predict or calculate :-)\u003c/p\u003e\u003cp\u003e(You will be scored by the accuracy).\u003c/p\u003e\u003cp\u003eUpdate: \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/about/trendy/\"\u003eTRENDY\u003c/a\u003e \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/trendy/Tutorial/urlfilter.html\"\u003eis\u003c/a\u003e here!\u003c/p\u003e","function_template":"function y = solutions(x)\r\n  y = 42;\r\nend","test_suite":"%%\r\n% please ''ignore'' this first test, this code is here to put function \r\n% urlfilter known from matlabcentral/trendy to the path for this problem\r\n% (method taken from Doug's Hull problem Steal, Share, or Catch)\r\nfh=fopen('urlfilter.m','wt');\r\nfprintf(fh, '%s \\n', 'function out = urlfilter(url, target, numNumbers, direction)') ;\r\nfprintf(fh, '%s \\n', '  if nargin \u003c 3, numNumbers = 1; end');\r\nfprintf(fh, '%s \\n', '  if nargin \u003c 4 direction = ''forward''; end');\r\nfprintf(fh, '%s \\n', '  % If url is not an actual URL, then treat it as a string');\r\nfprintf(fh, '%s \\n', '  if strcmp(url(1:4),''http''), textStr = urlread(url); else textStr = url; end');\r\nfprintf(fh, '%s \\n', '  % Handle special case where two numbers are given as part of a range');\r\nfprintf(fh, '%s \\n', '  %   Example: \"annual rainfall = 20-40 inches\"');\r\nfprintf(fh, '%s \\n', '  % Solution is a pre-processing step that replaces the dash with a space');\r\nfprintf(fh, '%s \\n', '  %   Example: \"annual rainfall = 20 40 inches\"');\r\nfprintf(fh, '%s \\n', '  textStr = regexprep(textStr,''(\\d+)-(\\d+)'',''$1 $2'');');\r\nfprintf(fh, '%s \\n', '  strIndex = strfind(textStr,target);');\r\nfprintf(fh, '%s \\n', '  if isempty(strIndex),');\r\nfprintf(fh, '%s \\n', '    error( ''trendy:urlfilter:TargetStringNotFound'', ...');\r\nfprintf(fh, '%s \\n', '          [''Target string '' target '' does not appear''])');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', '  % Start looking after the first appearance of the target');\r\nfprintf(fh, '%s \\n', '  if strcmp(direction,''forward'')');\r\nfprintf(fh, '%s \\n', '    strIndex = strIndex(1) + length(target);');\r\nfprintf(fh, '%s \\n', '  elseif strcmp(direction,''backward'')');\r\nfprintf(fh, '%s \\n', '    strIndex = strIndex(1) - 1;');\r\nfprintf(fh, '%s \\n', '  else');\r\nfprintf(fh, '%s \\n', '    error( ''trendy:urlfilter:InvalidDirectionFlag'', ...');\r\nfprintf(fh, '%s \\n', '           ''DIRECTION must be either ''''forward'''' or ''''backward''''.'' );');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', '  out = zeros(1,numNumbers);');\r\nfprintf(fh, '%s \\n', '  for i = 1:numNumbers');\r\nfprintf(fh, '%s \\n', '    [out(i),strIndex] = getNextNumber(textStr,strIndex,direction);');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', 'end');\r\nfprintf(fh, '%s \\n', '% =========================');\r\nfprintf(fh, '%s \\n', 'function [nextNumber,strIndex] = getNextNumber(textStr,strIndex,direction)');\r\nfprintf(fh, '%s \\n', '  % Use a state machine to sift through the HTML for numbers.');\r\nfprintf(fh, '%s \\n', '  if strcmp(direction,''forward'')');\r\nfprintf(fh, '%s \\n', '    openTagSymbol  = ''\u003c'';');\r\nfprintf(fh, '%s \\n', '    closeTagSymbol = ''\u003e'';');\r\nfprintf(fh, '%s \\n', '    moveIndexFcn   = @(x) x+1;');\r\nfprintf(fh, '%s \\n', '    concatenateFcn = @(a,b) [a b];');\r\nfprintf(fh, '%s \\n', '  else');\r\nfprintf(fh, '%s \\n', '    openTagSymbol  = ''\u003e'';');\r\nfprintf(fh, '%s \\n', '    closeTagSymbol = ''\u003c'';');\r\nfprintf(fh, '%s \\n', '    moveIndexFcn   = @(x) x-1;');\r\nfprintf(fh, '%s \\n', '    concatenateFcn = @(a,b) [b a];');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', '  urlStrLen = length(textStr);');\r\nfprintf(fh, '%s \\n', '  state = ''notnumber'';');\r\nfprintf(fh, '%s \\n', '  while true');\r\nfprintf(fh, '%s \\n', '    ch = textStr(strIndex);');\r\nfprintf(fh, '%s \\n', '    switch state');\r\nfprintf(fh, '%s \\n', '      case ''notnumber''');\r\nfprintf(fh, '%s \\n', '        if isDigitDotDashOrComma(ch)');\r\nfprintf(fh, '%s \\n', '          state = ''number'';');\r\nfprintf(fh, '%s \\n', '          numStr = ch;');\r\nfprintf(fh, '%s \\n', '        elseif (ch == openTagSymbol)');\r\nfprintf(fh, '%s \\n', '          state = ''tagbody'';');\r\nfprintf(fh, '%s \\n', '        end');\r\nfprintf(fh, '%s \\n', '      case ''tagbody''');\r\nfprintf(fh, '%s \\n', '        % Throw away anything inside the tag markup area');\r\nfprintf(fh, '%s \\n', '        if (ch == closeTagSymbol)');\r\nfprintf(fh, '%s \\n', '          state = ''notnumber'';');\r\nfprintf(fh, '%s \\n', '        end ');\r\nfprintf(fh, '%s \\n', '      case ''number''');\r\nfprintf(fh, '%s \\n', '        if isDigitDotDashOrComma(ch)');\r\nfprintf(fh, '%s \\n', '          numStr = concatenateFcn(numStr,ch);');\r\nfprintf(fh, '%s \\n', '        else');\r\nfprintf(fh, '%s \\n', '          % We are transitioning out of a number.');\r\nfprintf(fh, '%s \\n', '          % Note that STR2DOUBLE handles commas in the string.');\r\nfprintf(fh, '%s \\n', '          nextNumber = str2double(numStr);');\r\nfprintf(fh, '%s \\n', '          if ~isnan(nextNumber)');\r\nfprintf(fh, '%s \\n', '            % The number is valid. We''re all done.');\r\nfprintf(fh, '%s \\n', '            break');\r\nfprintf(fh, '%s \\n', '          else');\r\nfprintf(fh, '%s \\n', '            % The number is bogus. Throw it away and continue.');\r\nfprintf(fh, '%s \\n', '            if (ch == openTagSymbol), state = ''tagbody''; else state = ''notnumber''; end');\r\nfprintf(fh, '%s \\n', '          end');\r\nfprintf(fh, '%s \\n', '        end');\r\nfprintf(fh, '%s \\n', '      otherwise');\r\nfprintf(fh, '%s \\n', '        error( ''trendy:urlfilter:InvalidState'', ...');\r\nfprintf(fh, '%s \\n', '             [''Encountered unknown state '' state])');\r\nfprintf(fh, '%s \\n', '    end');\r\nfprintf(fh, '%s \\n', '    strIndex = moveIndexFcn(strIndex);');\r\nfprintf(fh, '%s \\n', '    if (strIndex == 0) || (strIndex \u003e urlStrLen)');\r\nfprintf(fh, '%s \\n', '      % We ran off the end of the string.');\r\nfprintf(fh, '%s \\n', '      disp(''End of file reached.'')');\r\nfprintf(fh, '%s \\n', '      break');\r\nfprintf(fh, '%s \\n', '    end');\r\nfprintf(fh, '%s \\n', '  end');\r\nfprintf(fh, '%s \\n', 'end');\r\nfprintf(fh, '%s \\n', '% ==================');\r\nfprintf(fh, '%s \\n', 'function tf = isDigitDotDashOrComma(ch)');\r\nfprintf(fh, '%s \\n', '  tf = ((ch \u003e= ''0'') \u0026\u0026 (ch \u003c= ''9'')) || ...');\r\nfprintf(fh, '%s \\n', '          (ch == ''.'') || (ch == ''-'') || (ch == '','');');\r\nfprintf(fh, '%s \\n', 'end');\r\nfclose(fh);\r\n%%\r\nrehash path\r\n%%\r\ny=solutions();\r\nassert(isequal(mod(y,1),0))\r\n%%\r\ny=solutions();\r\nassert(y\u003e0);\r\n%%\r\ny=solutions();\r\n% yes, yes solution hidden in the test suite... try to code adifferent one! :-)\r\nurl='http://www.mathworks.co.uk/matlabcentral/cody/problems/2312'\r\ny_correct=max([0 cellfun(@(S)str2num(cell2mat(S)),regexp(urlread(url),'\u003cspan class=\"solution_statistic\"\u003e(\\d*)\u003c/span\u003e\u003cspan class=\"text\"\u003e Solutions\u003c/span\u003e','tokens'))]) + 1; % don't forget your solution\r\nt = mtree('solutions.m','-file');\r\nsize = ceil(length(t.nodesize)/13);\r\nfeval(@assignin,'caller','score',abs(y-y_correct)+size);\r\n% (... and solutions will be rescored from time to time :-D)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":"2014-05-12T12:02:31.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-05-08T08:33:51.000Z","updated_at":"2026-02-18T14:23:20.000Z","published_at":"2014-05-08T09:06:48.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\u003eGuess, predict or calculate :-)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e(You will be scored by the accuracy).\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eUpdate:\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.co.uk/matlabcentral/about/trendy/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eTRENDY\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\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/trendy/Tutorial/urlfilter.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eis\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e here!\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":2424,"title":"Latest Question On Cody","description":"Get the problem number of the latest submitted Problem on Cody. Copying the test suite code might not help.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; vertical-align: baseline; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; \"\u003e\u003cspan style=\"\"\u003eGet the problem number of the latest submitted Problem on Cody. Copying the test suite code might not help.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = numProb()\r\n\r\nend","test_suite":"%%\r\ntic\r\nurl = 'https://www.mathworks.com/matlabcentral/cody/problems?term=\u0026sort=created+desc';\r\nhtml = urlread(url);\r\npattern = ['\"problem_[0-9]+\"'];\r\nc = regexp(html,pattern,'match');\r\nq = c{1};\r\nn = str2num(q(isstrprop(q,'digit')));\r\nt_act = toc;\r\n\r\n\r\ntic\r\nn1 = numProb();\r\nt_1 = toc;\r\n\r\ntest_result = isequal(n1,n);\r\nif test_result\r\n    disp(\"The solution works.\")\r\nelse\r\n    assert(false);\r\nend\r\nassert(t_1\u003c=(t_act*0.95));\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":17203,"edited_by":26769,"edited_at":"2022-04-12T12:44:32.000Z","deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":"2022-04-12T12:44:32.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-07-14T08:42:16.000Z","updated_at":"2025-12-08T23:36:16.000Z","published_at":"2014-07-14T08:42:16.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGet the problem number of the latest submitted Problem on Cody. Copying the test suite code might not help.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":699,"title":"Reading Web Binary Files (jpg,pdf,tiff,png)","description":"The Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\r\n\r\n.\r\n\r\nAccessing files on the web provide multiple challenges due to the data structures being text or binary.\r\n\r\nThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\r\n\r\n\r\n\r\nInput:\r\n\r\nfname 'http://some valid location/file.pdf'\r\n\r\nn      The byte for which the value is being requested.\r\n\r\nOutput: Value of the byte, an integer ranging from 0 to 255\r\n\r\n.\r\n\r\n\r\nA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\r\n\r\nA urlreadbin can be readily created to directly push the file to an array.","description_html":"\u003cp\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/p\u003e\u003cp\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\u003c/p\u003e\u003cp\u003eInput:\u003c/p\u003e\u003cp\u003efname 'http://some valid location/file.pdf'\u003c/p\u003e\u003cp\u003en      The byte for which the value is being requested.\u003c/p\u003e\u003cp\u003eOutput: Value of the byte, an integer ranging from 0 to 255\u003c/p\u003e\u003cp\u003e.\u003c/p\u003e\u003cp\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/p\u003e\u003cp\u003eA urlreadbin can be readily created to directly push the file to an array.\u003c/p\u003e","function_template":"function y = access_web_pdf(fname,n)\r\n  y = 0;\r\nend","test_suite":"%%\r\n% Cody External accessibility\r\n\r\n% This file may need to change in the future\r\nin_f='http://www.pvplc.org/_volunteer/docs/PVPLC%20Trail%20Crew%20Training%20Jan-Jun%202012.pdf';\r\n\r\nout_f='PVPLC.pdf';\r\n\r\nurlwrite(in_f,out_f);\r\n\r\nfid=fopen(out_f);\r\nurlwrite_out=fread(fid,128,'*uint8'); \r\n% Display Correct Binary Data\r\nurlwrite_out(1:16)'\r\n\r\n\r\nblock=urlread(in_f);\r\n% Display invalid binary data\r\nurlread_out=block(1:16)-char(0)\r\n% unicode urlread conversion affects bytes 12 thru 15\r\n\r\nn=12\r\nbyte_val = access_web_pdf(in_f,n)\r\n\r\nbyte_correct=181;\r\n\r\nassert(isequal(byte_val,byte_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-05-18T04:26:21.000Z","updated_at":"2012-05-21T05:35:07.000Z","published_at":"2012-05-21T05:35:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Challenge is to access a Web binary file, a PDF in this case, and provide the value of a specific byte.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAccessing files on the web provide multiple challenges due to the data structures being text or binary.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe functions urlread and urlwrite both access web files but provide different results for binary files. (jpg, pdf, tiff, png, ppt)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003efname 'http://some valid location/file.pdf'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en The byte for which the value is being requested.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput: Value of the byte, an integer ranging from 0 to 255\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA solution exists in the test suite to show the different data created by urlread and urlwrite for binary data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA urlreadbin can be readily created to directly push the file to an array.\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":877,"title":"What is Title of Cody Challenge 42?","description":"Given a Cody Challenge number return its Title.\r\n\r\n*Input:* Cody Challenge Number\r\n\r\n*Output:* Title of the Cody Challenge\r\n\r\n  1 'Times 2 - START HERE'  \r\n  2 'Make the vector [1 2 3 4 5 6 7 8 9 10]' \r\n110 'Make an N-dimensional Multiplication Table'\r\n808 'Hamming Weight - Fast'  \r\n\r\n\r\nFor my methods this was non-trivial due to hyperlink issues.\r\n\r\n Warning:What \"you\" may see is not what you \"get\"\r\n Can anyone \"get\" the title to challenge 4?\r\n My method faces many blocked challenge numbers.\r\n\r\n(I retain the right to add cases if hard coded answers are invoked and become the leading solution size)","description_html":"\u003cp\u003eGiven a Cody Challenge number return its Title.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e Cody Challenge Number\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e Title of the Cody Challenge\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 'Times 2 - START HERE'  \r\n2 'Make the vector [1 2 3 4 5 6 7 8 9 10]' \r\n110 'Make an N-dimensional Multiplication Table'\r\n808 'Hamming Weight - Fast'  \r\n\u003c/pre\u003e\u003cp\u003eFor my methods this was non-trivial due to hyperlink issues.\u003c/p\u003e\u003cpre\u003e Warning:What \"you\" may see is not what you \"get\"\r\n Can anyone \"get\" the title to challenge 4?\r\n My method faces many blocked challenge numbers.\u003c/pre\u003e\u003cp\u003e(I retain the right to add cases if hard coded answers are invoked and become the leading solution size)\u003c/p\u003e","function_template":"function Title = Cody_Title(n)\r\n  Title='Good Luck';\r\nend","test_suite":"%%\r\nn = 1;\r\nTitle_correct = 'Times 2 - START HERE';\r\nassert(strcmp(Cody_Title(n),Title_correct))\r\n%%\r\nn = 2;\r\nTitle_correct = 'Make the vector [1 2 3 4 5 6 7 8 9 10]';\r\nassert(strcmp(Cody_Title(n),Title_correct))\r\n%%\r\nn = 110;\r\nTitle_correct = 'Make an N-dimensional Multiplication Table';\r\n% This problem hurts my head\r\nassert(strcmp(Cody_Title(n),Title_correct))\r\n%%\r\nn = 808;\r\nTitle_correct = 'Hamming Weight - Fast';\r\nassert(strcmp(Cody_Title(n),Title_correct))","published":true,"deleted":false,"likes_count":6,"comments_count":3,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":32,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2012-08-04T14:40:09.000Z","updated_at":"2025-12-27T16:14:18.000Z","published_at":"2012-08-04T16:25:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a Cody Challenge number return its Title.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003cw:r\u003e\u003cw:t\u003e Cody Challenge Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw: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 Title of the Cody Challenge\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 'Times 2 - START HERE'  \\n2 'Make the vector [1 2 3 4 5 6 7 8 9 10]' \\n110 'Make an N-dimensional Multiplication Table'\\n808 'Hamming Weight - Fast']]\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\u003eFor my methods this was non-trivial due to hyperlink issues.\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[ Warning:What \\\"you\\\" may see is not what you \\\"get\\\"\\n Can anyone \\\"get\\\" the title to challenge 4?\\n My method faces many blocked challenge numbers.]]\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\u003e(I retain the right to add cases if hard coded answers are invoked and become the leading solution size)\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":779,"title":"Read a Text file from a URL and create an {N x 1}  Cell Array","description":"Given a URL string for a text file, read the text file and store the contents into a cell array.\r\n\r\nThe text file will have contiguous characters on different lines.\r\n\r\n*Inputs:*\r\n\r\nURL/File string  (eg 'http://www.toobigforemail.com/cryptkeeper.toobig?npp=xgz8xdyx') (This is close but not a valid link)\r\n\r\nThis is a link to a text file.\r\n\r\nNote: I tried to use my Google WebPage but it is an \"https\".\r\n\r\nurlread for 2012a does not like https sites.  (2012b???)\r\n\r\n*Typical Text File:*\r\n\r\nread2cell.txt\r\n\r\nabcd\r\n\r\nwxyz\r\n\r\n*Output:*\r\n\r\n{2x1 cell}\r\n\r\n'abcd'\r\n\r\n'wxyz'\r\n \r\n\r\nThis is intended as an introductory function usage.\r\n\r\nFollow up will be, \"Is it a valid scrabble word?\", once I find that scrabble dictionary.","description_html":"\u003cp\u003eGiven a URL string for a text file, read the text file and store the contents into a cell array.\u003c/p\u003e\u003cp\u003eThe text file will have contiguous characters on different lines.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInputs:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eURL/File string  (eg 'http://www.toobigforemail.com/cryptkeeper.toobig?npp=xgz8xdyx') (This is close but not a valid link)\u003c/p\u003e\u003cp\u003eThis is a link to a text file.\u003c/p\u003e\u003cp\u003eNote: I tried to use my Google WebPage but it is an \"https\".\u003c/p\u003e\u003cp\u003eurlread for 2012a does not like https sites.  (2012b???)\u003c/p\u003e\u003cp\u003e\u003cb\u003eTypical Text File:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eread2cell.txt\u003c/p\u003e\u003cp\u003eabcd\u003c/p\u003e\u003cp\u003ewxyz\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e{2x1 cell}\u003c/p\u003e\u003cp\u003e'abcd'\u003c/p\u003e\u003cp\u003e'wxyz'\u003c/p\u003e\u003cp\u003eThis is intended as an introductory function usage.\u003c/p\u003e\u003cp\u003eFollow up will be, \"Is it a valid scrabble word?\", once I find that scrabble dictionary.\u003c/p\u003e","function_template":"function dict = read_url_txtfn2cellarray(url_fname)\r\n  dict = {};\r\nend","test_suite":"%%\r\n%read2cell.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyefee\u00266cq_kc2=yae1ad\u00266cq_konmpb=xgz8yxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd';'wxyz';'mn  ';'pqr ']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))\r\n%%\r\n%read2cell02.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyeffg\u00266cq_kc2=yae1af\u00266cq_konmpb=8x1eyxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd';'wxyz']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))\r\n%%\r\n%read2cell03.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyeffg\u00266cq_kc2=yae1dg\u00266cq_konmpb=8x1eyxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd';'wxyz';'123 ']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))\r\n%%\r\n%read2cell04.txt\r\nurl_fname='http://www.toobigforemail.com/cryptkeeper.toobig?nppmkc2=xyeffg\u00266cq_kc2=yae1d1\u00266cq_konmpb=y88ayxyx8xxy1xdyx';\r\ndata_v{1}=cellstr(['abcd ';'wxyz ';'123  ';'mnopq';'hij  ']);\r\nassert(isequal(read_url_txtfn2cellarray(url_fname),data_v))","published":true,"deleted":false,"likes_count":0,"comments_count":5,"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-06-21T04:02:33.000Z","updated_at":"2012-06-22T02:54:47.000Z","published_at":"2012-06-22T02:54:47.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a URL string for a text file, read the text file and store the contents into a cell 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\u003eThe text file will have contiguous characters on different lines.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eInputs:\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eURL/File string (eg 'http://www.toobigforemail.com/cryptkeeper.toobig?npp=xgz8xdyx') (This is close but not a valid link)\u003c/w:t\u003e\u003c/w:r\u003e\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 a link to a text file.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eNote: I tried to use my Google WebPage but it is an \\\"https\\\".\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eurlread for 2012a does not like https sites. (2012b???)\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eTypical Text File:\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eread2cell.txt\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eabcd\u003c/w:t\u003e\u003c/w:r\u003e\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\u003ewxyz\u003c/w:t\u003e\u003c/w:r\u003e\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\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e{2x1 cell}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'abcd'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e'wxyz'\u003c/w:t\u003e\u003c/w:r\u003e\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 intended as an introductory function usage.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eFollow up will be, \\\"Is it a valid scrabble word?\\\", once I find that scrabble dictionary.\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":1949,"title":"Get top 5 Cody Player Emails Automatically","description":"Yes, this is a little scary and also entirely possible to do in MATLAB, so let's do it!\r\n\r\nLooking at the list of the players \u003chttp://www.mathworks.com/matlabcentral/cody/players\u003e automatically sorts them in order according to rank. For times sake, let's say we only want to get the emails from the first 5 people. This is relatively easy to do by hand, just click on the persons name, click on \"View Profile Information\" and you have the email but if you wanted to do say the first 1,000 people instead, that would be not very fun to do by hand. \r\n\r\nFor this program, let's say we want the top 5 profiles that give a \"real\" email address (not a contact form) to be in a cell array. This means that if one of the top 5 people have removed their email address, your returned cell array will have less than 5 emails in it. \r\n\r\nIf you are not sure where to start, check out the urlread command, it allows you to put the web page source code into a string. From there, you are able to parse through that to get the URLs for the top 5 players web profile. From there, look for a \"mailto:\" and if it is there, the email address is immediately following it. If the string \"mailto:\" does not exist, there is no email address on that webpage. Put the emails in a cell array when you find them and you are good to go!\r\n\r\nAs an example, I have poorly written MATLAB code that works in the test case since I want the test case to always be accurate. 98% of the execution time is spent reading the webpages, and at least on my computer, that takes quite a while to do (about 2.5 seconds per profile page).\r\n\r\n*I am definitely not collecting emails for anything, and you should not either! This is designed solely as a learning example and should in no way be used for anything unethical. All information obtained here is easily obtained by anyone in the world who knows how to program.*\r\n\r\n*If this scares you and you want to remove your email address from your profile, it's easy. All you have to do is click \"My Community Profile\" (underneath the search bar at very top of screen) and then edit your preferences to not display your email address.* ","description_html":"\u003cp\u003eYes, this is a little scary and also entirely possible to do in MATLAB, so let's do it!\u003c/p\u003e\u003cp\u003eLooking at the list of the players \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/players\"\u003ehttp://www.mathworks.com/matlabcentral/cody/players\u003c/a\u003e automatically sorts them in order according to rank. For times sake, let's say we only want to get the emails from the first 5 people. This is relatively easy to do by hand, just click on the persons name, click on \"View Profile Information\" and you have the email but if you wanted to do say the first 1,000 people instead, that would be not very fun to do by hand.\u003c/p\u003e\u003cp\u003eFor this program, let's say we want the top 5 profiles that give a \"real\" email address (not a contact form) to be in a cell array. This means that if one of the top 5 people have removed their email address, your returned cell array will have less than 5 emails in it.\u003c/p\u003e\u003cp\u003eIf you are not sure where to start, check out the urlread command, it allows you to put the web page source code into a string. From there, you are able to parse through that to get the URLs for the top 5 players web profile. From there, look for a \"mailto:\" and if it is there, the email address is immediately following it. If the string \"mailto:\" does not exist, there is no email address on that webpage. Put the emails in a cell array when you find them and you are good to go!\u003c/p\u003e\u003cp\u003eAs an example, I have poorly written MATLAB code that works in the test case since I want the test case to always be accurate. 98% of the execution time is spent reading the webpages, and at least on my computer, that takes quite a while to do (about 2.5 seconds per profile page).\u003c/p\u003e\u003cp\u003e\u003cb\u003eI am definitely not collecting emails for anything, and you should not either! This is designed solely as a learning example and should in no way be used for anything unethical. All information obtained here is easily obtained by anyone in the world who knows how to program.\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eIf this scares you and you want to remove your email address from your profile, it's easy. All you have to do is click \"My Community Profile\" (underneath the search bar at very top of screen) and then edit your preferences to not display your email address.\u003c/b\u003e\u003c/p\u003e","function_template":"function emails = getCodyEmails()\r\n  emails = {};\r\nend","test_suite":"%%\r\n% My code is below, it's used to generate the expected result.\r\n\r\n%Read in the player page\r\nplayerPage=urlread('http://www.mathworks.com/matlabcentral/cody/players');\r\n\r\n%Find where the web address for each profile starts\r\nstartIdx=strfind(playerPage,'\u003cdiv class=\"grid_53 push_3\"\u003e')+104; \r\n\r\n%Initialize output array\r\nemails={};\r\n\r\n%Get top 5 only\r\nfor i=1:5\r\n    % Get the profile page link\r\n   tempStr=playerPage(startIdx(i):startIdx(i)+100);\r\n   quoteIdx=strfind(tempStr,'\"')-1;\r\n   profilePageLink=['http://www.mathworks.com' tempStr(1:quoteIdx(1))];\r\n   \r\n   profilePage=urlread(profilePageLink);\r\n   % Try and find mailto link\r\n   tStartIdx=strfind(profilePage,'mailto');\r\n   \r\n   %If you could find it\r\n   if ~isempty(tStartIdx)\r\n       % Get the email\r\n       tEndIdx=strfind(profilePage(tStartIdx:tStartIdx+100),'\"')+tStartIdx;\r\n       \r\n       % Add it to our cell array\r\n       emails{length(emails)+1}=profilePage(tStartIdx+7:tEndIdx-2);\r\n   end\r\n    \r\nend\r\n\r\n\r\ntic\r\nyourResponse=getCodyEmails()\r\ntimeElapsed=toc\r\n\r\n\r\nassert(isequal(yourResponse,emails))\r\nassert(isequal(1,timeElapsed\u003e3))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":3743,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-10-20T05:40:10.000Z","updated_at":"2025-07-31T17:14:24.000Z","published_at":"2013-10-20T05:40:10.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\u003eYes, this is a little scary and also entirely possible to do in MATLAB, so let's do it!\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eLooking at the list of the players\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/players\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.mathworks.com/matlabcentral/cody/players\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e automatically sorts them in order according to rank. For times sake, let's say we only want to get the emails from the first 5 people. This is relatively easy to do by hand, just click on the persons name, click on \\\"View Profile Information\\\" and you have the email but if you wanted to do say the first 1,000 people instead, that would be not very fun to do by hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this program, let's say we want the top 5 profiles that give a \\\"real\\\" email address (not a contact form) to be in a cell array. This means that if one of the top 5 people have removed their email address, your returned cell array will have less than 5 emails in it.\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eIf you are not sure where to start, check out the urlread command, it allows you to put the web page source code into a string. From there, you are able to parse through that to get the URLs for the top 5 players web profile. From there, look for a \\\"mailto:\\\" and if it is there, the email address is immediately following it. If the string \\\"mailto:\\\" does not exist, there is no email address on that webpage. Put the emails in a cell array when you find them and you are good to go!\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eAs an example, I have poorly written MATLAB code that works in the test case since I want the test case to always be accurate. 98% of the execution time is spent reading the webpages, and at least on my computer, that takes quite a while to do (about 2.5 seconds per profile page).\u003c/w:t\u003e\u003c/w:r\u003e\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\u003eI am definitely not collecting emails for anything, and you should not either! This is designed solely as a learning example and should in no way be used for anything unethical. All information obtained here is easily obtained by anyone in the world who knows how to program.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eIf this scares you and you want to remove your email address from your profile, it's easy. All you have to do is click \\\"My Community Profile\\\" (underneath the search bar at very top of screen) and then edit your preferences to not display your email address.\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:\"urlread\"","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:\"urlread\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"urlread\"","","\"","urlread","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8178\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2ccdf80d8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf5dd8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8538\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8498\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2ccdf82b8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2ccdf8218\u003e":"tag:\"urlread\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8218\u003e":"tag:\"urlread\""},"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:\"urlread\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"urlread\"","","\"","urlread","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8178\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2ccdf80d8\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf5dd8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8538\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8498\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2ccdf82b8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2ccdf8218\u003e":"tag:\"urlread\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2ccdf8218\u003e":"tag:\"urlread\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2312,"difficulty_rating":"easy"},{"id":2424,"difficulty_rating":"easy"},{"id":699,"difficulty_rating":"easy-medium"},{"id":877,"difficulty_rating":"easy-medium"},{"id":779,"difficulty_rating":"medium"},{"id":1949,"difficulty_rating":"medium-hard"}]}}