Cody

# Problem 1301. RISK Calculator - Large Armies, High Accuracy, Fast

Solution 497469

Submitted on 8 Sep 2014 by Bart
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% feval(@assignin,'caller','score',5000); % msec

2   Pass
%% a=[100 99 100 10 9 2 2 10 30 70]; d=[100 100 99 9 10 1 2 2 30 80]; y_c=[0.8079031789315619 0.7888693135658454 0.8230449788340404 0.5580697529719042 0.3798720048109818 0.4166666666666667 0.10609567901234569 0.9901146432872121 0.633266311153744 0.5011352886279803]; tsum=0; for i=1:length(a) ta=clock; y=risk_prob(a(i), d(i)); t1=etime(clock,ta)*1000; % time in msec tsum=tsum+t1; assert(abs(y - y_c(i)) <= 1e-6,sprintf('A=%i D=%i Expect=%.9f pwin=%.9f',a(i),d(i),y_c(i),y)) fprintf('A %3i D %3i Time(msec) %7.3f\n',a(i),d(i),t1); end feval( @assignin,'caller','score',floor(min( 5000,tsum )) );

pwin = 0.8079 A 100 D 100 Time(msec) 460.664 pwin = 0.7889 A 99 D 100 Time(msec) 386.443 pwin = 0.8230 A 100 D 99 Time(msec) 385.903 pwin = 0.5581 A 10 D 9 Time(msec) 0.715 pwin = 0.3799 A 9 D 10 Time(msec) 0.566 pwin = 0.4167 A 2 D 1 Time(msec) 0.352 pwin = 0.1061 A 2 D 2 Time(msec) 0.340 pwin = 0.9901 A 10 D 2 Time(msec) 0.399 pwin = 0.6333 A 30 D 30 Time(msec) 6.887 pwin = 0.5011 A 70 D 80 Time(msec) 136.446

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!