Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

119Size
Leading solution size is 59.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
% My code is below, it's used to generate the expected result.
%Read in the player page
playerPage=urlread('http://www.mathworks.com/matlabcentral/cody/players');
%Find where the web address for each profile starts
startIdx=strfind(playerPage,'<div class="grid_53 push_3">')+104;
%Initialize output array
emails={};
%Get top 5 only
for i=1:5
    % Get the profile page link
   tempStr=playerPage(startIdx(i):startIdx(i)+100);
   quoteIdx=strfind(tempStr,'"')-1;
   profilePageLink=['http://www.mathworks.com' tempStr(1:quoteIdx(1))];
   profilePage=urlread(profilePageLink);
   % Try and find mailto link
   tStartIdx=strfind(profilePage,'mailto');
   %If you could find it
   if ~isempty(tStartIdx)
       % Get the email
       tEndIdx=strfind(profilePage(tStartIdx:tStartIdx+100),'"')+tStartIdx;
       % Add it to our cell array
       emails{length(emails)+1}=profilePage(tStartIdx+7:tEndIdx-2);
   end
end
tic
yourResponse=getCodyEmails()
timeElapsed=toc
assert(isequal(yourResponse,emails))
assert(isequal(1,timeElapsed>3))
yourResponse =
    'alfnie@gmail.com'    'razapor@cox.net'    [1x23 char]    [1x30 char]
timeElapsed =
    8.3955