Cody

Problem 539. Fun Race

Solution 83072

Submitted on 27 Apr 2012 by Ben Petschel
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
%% foo=@cosh; goo=@(x)sqrt(cosh(x)+pi); winner=[]; for k=1:10; winner(end+1)=race(foo,goo); end assert(all(winner==1))

t1 = 0.0742 t2 = 0.2955 t1 = 0.0556 t2 = 0.2951 t1 = 0.0565 t2 = 0.2957 t1 = 0.0559 t2 = 0.2952 t1 = 0.0560 t2 = 0.2958 t1 = 0.0561 t2 = 0.2952 t1 = 0.0557 t2 = 0.2940 t1 = 0.0554 t2 = 0.2928 t1 = 0.0553 t2 = 0.2954 t1 = 0.0560 t2 = 0.2964

2   Pass
%% foo=@num2str; goo=@log10; winner=[]; for k=1:10; winner(end+1)=race(foo,goo); end assert(all(winner==2))

t1 = 1.2347 t2 = 0.0710 t1 = 1.1961 t2 = 0.0618 t1 = 1.1952 t2 = 0.0620 t1 = 1.1940 t2 = 0.0610 t1 = 1.2180 t2 = 0.0635 t1 = 1.2207 t2 = 0.0618 t1 = 1.1869 t2 = 0.0619 t1 = 1.1969 t2 = 0.0622 t1 = 1.1973 t2 = 0.0613 t1 = 1.2007 t2 = 0.0611

3   Pass
%% foo=@gamma; goo=@sign; winner=[]; for k=1:10; winner(end+1)=race(foo,goo); end assert(all(winner==1))

t1 = 0.0530 t2 = 0.0540 t1 = 0.0240 t2 = 0.0528 t1 = 0.0236 t2 = 0.0535 t1 = 0.0237 t2 = 0.0543 t1 = 0.0236 t2 = 0.0532 t1 = 0.0238 t2 = 0.0537 t1 = 0.0250 t2 = 0.0537 t1 = 0.0241 t2 = 0.0537 t1 = 0.0240 t2 = 0.0533 t1 = 0.0241 t2 = 0.0530

Suggested Problems

More from this Author100

Community Treasure Hunt

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

Start Hunting!