Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 242900

Submitted on 11 May 2013 by G K

Correct

74Size
Leading solution size is 49.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
tic
N=4;T=6;B=3;S=5;
p=supplies(N,T,B,S);
assert(isequal(p,3))

                    
2
Pass
 
%%
N=4;T=3;B=6;S=1;
p=supplies(N,T,B,S);
assert(isequal(p,4))

                    
3
Pass
 
%%
N=3;T=4;B=2;S=4;
p=supplies(N,T,B,S);
assert(isequal(p,2))

                    
4
Pass
 
%%
N=3;T=3;B=1;S=1;
p=supplies(N,T,B,S);
assert(isequal(p,3))

                    
5
Pass
 
%%
N=2;T=1;B=9;S=1;
p=supplies(N,T,B,S);
assert(isequal(p,2))

                    
6
Pass
 
%%
N=7;T=5;B=3;S=3;
p=supplies(N,T,B,S);
assert(isequal(p,6))

                    
7
Pass
 
%%
N=7;T=5;B=100;S=2;
p=supplies(N,T,B,S);
assert(isequal(p,7))

                    
8
Pass
 
%%
N=8;T=3;B=1;S=3;
p=supplies(N,T,B,S);
assert(isequal(p,8))

                    
9
Pass
 
%%
N=100;T=50;B=100;S=25;
p=supplies(N,T,B,S);
assert(isequal(p,75))

                    
10
Pass
 
%%
N=99;T=100;B=99;S=7;
p=supplies(N,T,B,S);
assert(isequal(p,99))

                    
11
Pass
 
%%
N=99;T=100;B=99;S=29;
p=supplies(N,T,B,S);
assert(isequal(p,99))

                    
12
Pass
 
%%
N=99;T=100;B=99;S=82;
p=supplies(N,T,B,S);
assert(isequal(p,99))

                    
13
Pass
 
%%
N=99;T=45;B=10;S=7;
p=supplies(N,T,B,S);
assert(isequal(p,97))
toc
Elapsed time is 0.027791 seconds.