Cody

# Problem 539. Fun Race

Solution 2913637

Submitted on 5 Sep 2020
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   Fail
foo=@cosh; goo=@(x)sqrt(cosh(x)+pi); winner=[]; for k=1:10; winner(end+1)=race(foo,goo); end assert(all(winner==1))

Unrecognized function or variable 'foo'. Error in race>@()foo(x) (line 4) f=@() foo(x); Error in timeit>numOutputs (line 241) a = f(); %#ok<NASGU> Error in timeit (line 50) num_outputs = min(numOutputs(f), 1); Error in race (line 5) p = timeit(f); Error in Test1 (line 4) for k=1:10; winner(end+1)=race(foo,goo); end

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

Unrecognized function or variable 'foo'. Error in race>@()foo(x) (line 4) f=@() foo(x); Error in timeit>numOutputs (line 241) a = f(); %#ok<NASGU> Error in timeit (line 50) num_outputs = min(numOutputs(f), 1); Error in race (line 5) p = timeit(f); Error in Test2 (line 4) for k=1:10; winner(end+1)=race(foo,goo); end

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

Unrecognized function or variable 'foo'. Error in race>@()foo(x) (line 4) f=@() foo(x); Error in timeit>numOutputs (line 241) a = f(); %#ok<NASGU> Error in timeit (line 50) num_outputs = min(numOutputs(f), 1); Error in race (line 5) p = timeit(f); Error in Test3 (line 4) for k=1:10; winner(end+1)=race(foo,goo); end

### Community Treasure Hunt

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

Start Hunting!