Haoyu Dai - MATLAB Cody - MATLAB Central

Haoyu Dai

8800
Rank
3
Badges
670
Score
1 – 50 of 86

Haoyu Dai submitted Solution 2653784 to Problem 76. De-dupe

on 5 Jul 2020

Haoyu Dai submitted Solution 2653775 to Problem 76. De-dupe

on 5 Jul 2020

Haoyu Dai submitted Solution 2653772 to Problem 76. De-dupe

on 5 Jul 2020

Haoyu Dai submitted a Comment to Solution 2413275

function y = common_by_row(x) y=[]; [r,c]=size(x); if r>0 a=x(1,:); cnt=zeros(1,c); for j=1:c for i=1:r if isempty(find(x(i,:)==x(1,j)))==0 cnt(j)=cnt(j)+1; end end end for j=1:c if cnt(j)==r&&x(1,j)~=NaN&&ismember(x(1,j),y)==0 y=[y x(1,j)]; end end y=sort(y); end end

on 29 May 2020

Haoyu Dai submitted a Comment to Solution 2411043

function b = matchPattern(a) b=[]; len=length(a(1,:))-1; [r,c]=size(a); pattern=zeros(r-1,len); for j=1:r for i=1:len if a(j,i+1)>a(j,i) pattern(j,i)=1; elseif a(j,i+1)<a(j,i) pattern(j,i)=-1; else pattern(j,i)=0; end end end for j=2:r if isequal(pattern(j,:),pattern(1,:))==1 b=[b j]; end end end

on 29 May 2020

Haoyu Dai submitted a Comment to Solution 2301094

function i = running_product(s) L=length(s); L1=L-4; tmp=0; i=0; for j=1:L1 m=str2num(s(j))*str2num(s(j+1))*str2num(s(j+2))*str2num(s(j+3))*str2num(s(j+4)); if m>tmp tmp=m; i=j; end end end

on 20 May 2020

Haoyu Dai submitted a Comment to Solution 2253868

function b = makingChange(a) cu=[10000,5000,2000,1000,500,200,100,50,25,10,5,1]; b=[]; m=a*100; for i=1:11 b(i)=floor(m/cu(i)); m=m-b(i)*cu(i); end b(12)=m; end

on 4 May 2020

Haoyu Dai submitted Solution 2249828 to Problem 27. Pangrams!

on 2 May 2020

1 – 50 of 86
Go to top of page