Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
% Create necessary files
mkdir +counter1
mkdir +counter2
fid = fopen('+counter1/count.m', 'w');fprintf(fid, 'function y=count,persistent x;if isempty(x), x=0; end,x=x+1;y=x;');fclose(fid);
fid = fopen('+counter2/count.m', 'w');fprintf(fid, 'function y=count,persistent x;if isempty(x), x=0; end,x=x+1;y=x;');fclose(fid);
rehash;
% Start counting with Counter 1
counter1.count; %1
counter1.count; %2
counter1.count; %3
counter1.count; %4
counter1.count; %5
counter1.count; %6
counter1.count; %7
% Start counting with Counter 2
counter2.count; %1
counter2.count; %2
counter2.count; %3
counter2.count; %4
% Your code goes here
your_code;
% Check if your solution is correct
%{
"I would prefer even to fail with honor than win by cheating."
Sophocles
%}
% Restart counting with Counter 1
assert(isequal(counter1.count,1))
assert(isequal(counter1.count,2))
assert(isequal(counter1.count,3))
assert(isequal(counter1.count,4))
assert(isequal(counter1.count,5))
assert(isequal(counter1.count,6))
assert(isequal(counter1.count,7))
% Keep counting with Counter 2
assert(isequal(counter2.count,5))
|
1961 Solvers
2261 Solvers
337 Solvers
4326 Solvers
Test if two numbers have the same digits
187 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!