Finish 2010-11-17 12:00:00 UTC

b3

by Abhisek Ukil

Status: Passed
Results: 431866 (cyc: 6, node: 300)
CPU Time: 0.087
Score: 86373.5
Submitted at: 2010-11-11 13:47:32 UTC
Scored at: 2010-11-11 13:48:06 UTC

Current Rank: 2920th (Highest: 51st )
Basis for: Lord of the rings (diff)

Comments
Please login or create a profile.
Code
function [tr, tc] = solver(chart, ai, bi, mt)

tr = [];
tc = [];

row=size(chart(:,:,1),1);
col=size(chart(:,:,1),2);

rowwind=chart(:,:,1);
colwind=chart(:,:,2);

[ar, ac] = ind2sub(size(chart(:,:,1)),ai);
[br, bc] = ind2sub(size(chart(:,:,1)),bi);

dr=br-ar;
dc=bc-ac;

dvrm=round(dr/(abs(dr)+abs(dc))*mt);
dvcm=round(dc/(abs(dr)+abs(dc))*mt);

tr=[tr dvrm];
tc=[tc dvcm];

dvr=0;
dvc=0;

cr=ar; 
cc=ac;

for i=1:1

dvrw=rowwind(cr,cc);
dvcw=colwind(cr,cc);

dvr=tr(end)+dvrw;
dvc=tc(end)+dvcw;

nr=cr+dvr;
nc=cc+dvc;


dr=br-nr;
dc=bc-nc;

dvrm=round(dr/(abs(dr)+abs(dc))*mt);
dvcm=round(dc/(abs(dr)+abs(dc))*mt);

tr=[tr dvrm];
tc=[tc dvcm];

cr=nr;
cc=nc;

if cr<=0 | cr >row | cc<=0 | cc >col 
    break
end


end