This is my code in matlab for flames game but unable to get expected output.
Please check the code and help me to solve the problem
In this i am comparing two strings and replacing matching charaecters with '/' and also counting and at the end counting the number(n) of remaining charaecters other than '/' and incrementing pointer for flames string until n becomes zero for five times and replacing all such charecters in flames with '/'
p=input('Enter the first string:'); o=input('Enter the second string:'); c=size(p,2); d=size(o,2); for i=1:c for j=1:d if(p(i)==o(j)) p(i)='/'; o(j)='/'; else disp('Do_nothing'); end end end f=0; for i=1:c if(p(i)~='/') f=f+1; else disp('Do_nothing'); end end q=0; for j=1:d if(o(j)~='/') q=q+1; else disp('Do_Nothing'); end end handles.g=f+q; n=0; h='FLAMES'; for m=1:handles.g n=n+1; end v=n; i=1; for v=1:5 while(n) if(n>1) n=n-1; if(h(i)~='S') i=i+1; elseif(h(i)=='S') i=0; elseif(h(i)=='/') i=i+1; n=n+1; end end if(n==1) if(h(i)~='S') i=i+1; elseif(h(i)=='S') i=0; elseif(h(i)=='/') i=i+1; n=n+1; end end end W=regexprep(h,'h(i)','/'); end %disp('So the relationship between you has:'); %k;
Thanks in advance.