Cody

# Problem 583. Implement a counter

Solution 88585

Submitted on 14 May 2012 by Binbin Qi
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
%% h = counter; assert(isequal(h(), 1)) assert(isequal(h(), 2)) assert(isequal(h(), 3)) assert(isequal(h(), 4)) assert(isequal(h(), 5))

ans = Columns 1 through 10 5 1 1 1 4 4 4 5 3 3 5 2 5 3 1 4 1 4 2 3 1 3 5 5 5 2 2 2 4 4 5 5 3 4 5 4 1 5 4 4 4 5 5 5 4 1 1 1 1 4 Columns 11 through 20 2 3 4 5 5 2 2 2 1 1 4 5 2 3 2 1 5 4 1 3 4 2 3 1 5 2 3 4 3 3 1 3 4 1 2 4 3 2 4 1 1 2 5 2 5 3 5 3 5 2 Columns 21 through 30 1 4 3 5 1 5 3 1 5 1 4 2 1 3 5 1 5 5 4 2 2 4 2 5 1 2 1 3 2 1 3 4 5 1 4 2 2 3 3 1 1 4 1 3 5 5 1 1 3 2 Columns 31 through 40 3 3 4 1 2 1 3 1 5 2 1 2 2 5 2 4 2 2 4 3 5 5 2 5 5 4 4 4 3 3 5 2 3 3 1 4 1 4 3 5 3 1 1 1 1 3 4 1 3 4 Columns 41 through 50 4 5 2 1 2 5 3 1 1 4 2 5 2 2 5 3 2 2 2 3 5 3 3 1 3 1 4 2 5 3 3 4 2 2 1 2 4 3 1 2 2 3 5 3 5 3 2 3 5 3 Columns 51 through 60 5 4 1 2 1 5 1 4 1 1 3 4 5 2 4 5 4 4 2 5 3 2 5 4 3 2 3 5 5 4 2 2 4 1 4 4 3 5 1 3 3 5 1 4 4 1 5 3 3 3 Columns 61 through 70 1 1 4 3 1 2 2 1 5 3 4 5 3 3 2 3 3 2 5 3 1 5 5 5 5 3 1 1 1 5 1 4 4 1 5 4 5 3 4 3 3 1 5 1 1 4 1 2 2 5 Columns 71 through 80 2 4 1 2 4 1 2 5 5 1 4 1 3 3 2 3 2 4 5 3 4 1 5 5 1 2 4 2 5 2 3 5 4 1 3 2 2 3 2 1 4 1 1 5 3 3 5 1 3 1 Columns 81 through 90 3 4 3 5 4 2 3 4 2 4 1 4 4 3 3 3 5 2 2 4 3 1 3 2 1 3 4 4 4 1 3 1 5 1 2 3 5 4 5 4 4 2 4 4 1 5 2 1 2 2 Columns 91 through 100 5 4 1 4 2 3 4 4 3 3 1 2 4 1 4 4 4 2 4 5 3 4 3 4 1 3 4 1 4 5 3 3 1 2 2 3 5 4 2 2 3 1 2 5 1 4 2 3 4 4 Columns 101 through 110 3 1 3 5 3 4 4 3 2 4 3 5 4 2 3 5 1 2 1 2 5 4 3 1 2 5 3 4 3 3 2 3 4 1 4 1 3 4 2 4 2 4 3 1 4 1 5 3 1 2 Columns 111 through 120 4 1 5 2 4 5 3 3 3 3 2 2 3 5 5 4 5 4 1 1 4 3 5 4 2 1 3 5 1 3 4 2 2 2 4 5 1 4 1 1 3 1 4 2 3 5 1 2 4 1 Columns 121 through 130 5 5 4 2 4 4 4 1 3 1 3 5 5 3 3 4 3 5 4 3 5 5 3 5 2 4 5 3 1 1 4 1 3 3 4 5 3 5 4 1 3 5 5 5 1 5 1 2 2 2 Columns 131 through 140 1 3 1 2 5 4 4 5 1 2 1 4 3 3 1 3 1 4 1 3 1 3 5 4 1 1 5 3 5 4 4 3 5 3 1 5 5 1 2 1 2 3 2 2 1 4 5 2 2 5 Columns 141 through 150 3 1 5 3 1 1 5 1 5 1 5 4 3 3 2 2 1 3 1 5 2 2 4 4 1 5 4 2 2 1 3 5 5 5 3 4 4 1 1 1 1 1 2 1 2 3 3 2 3 2 Columns 151 through 160 3 1 4 3 4 3 4 2 3 1 1 2 1 1 1 4 3 4 3 1 5 1 1 5 1 4 2 4 5 1 2 3 4 2 4 4 1 1 4 4 2 4 5 2 4 2 4 1 4 5 Columns 161 through 170 4 4 4 1 4 2 3 2 1 3 1 2 2 2 2 2 1 3 4 4 4 4 4 2 2 3 4 1 2 4 1 4 5 4 1 2 1 3 4 3 1 3 5 3 4 4 2 1 5 4 Columns 171 through 180 1 3 4 2 1 3 1 2 3 4 5 4 3 4 1 1 1 2 1 3 1 2 3 4 3 4 1 2 2 2 2 2 4 1 4 1 1 5 1 1 4 1 1 1 4 1 2 4 5 4 Columns 181 through 190 5 4 1 2 3 2 1 5 4 3 1 3 2 4 2 3 1 5 4 2 2 5 1 2 2 4 2 3 4 1 2 3 4 3 3 3 2 2 1 5 1 4 5 5 3 3 4 4 4 1 Columns 191 through 200 1 1 5 3 1 5 4 4 2 4 4 5 4 2 5 4 2 4 5 5 5 3 1 3 4 3 1 3 4 3 3 4 3 1 5 3 4 2 5 1 4 1 2 2 1 2 4 5 3 5 Columns 201 through 210 4 4 1 3 2 1 4 5 2 5 2 2 4 1 2 4 1 2 2 1 5 1 2 5 1 2 5 4 3 3 2 1 5 2 4 4 5 3 2 1 4 3 4 5 1 2 4 3 5 5 Columns 211 through 220 5 4 1 4 5 4 3 3 2 3 1 3 2 5 4 2 4 3 5 2 5 5 1 2 5 2 4 1 2 1 1 5 1 3 4 4 3 4 5 2 4 4 1 5 2 3 3 5 3 4 Columns 221 through 230 4 4 2 2 1 5 2 5 3 5 4 1 2 1 1 1 1 4 3 1 1 2 4 5 1 1 2 1 5 2 5 4 3 4 3 3 2 2 5 5 5 4 4 5 1 4 3 1 3 5 Columns 231 through 240 4 4 5 2 3 4 2 4 4 5 4 4 2 4 4 5 2 1 5 1 2 5 3 2 5 1 4 2 2 3 5 2 5 4 2 2 4 3 4 2 1 4 3 3 5 4 3 2 1 5 Columns 241 through 250 3 5 3 1 3 1 5 4 2 5 3 1 4 1 1 2 2 3 1 3 5 5 2 5 2 1 1 4 1 1 2 1 4 4 2 5 2 5 4 5 3 4 5 2 2 1 4 1 4 5 Columns 251 through 260 2 3 3 2 1 2 5 3 5 5 3 3 4 4 3 5 3 4 5 4 5 3 2 4 2 5 4 3 2 2 4 2 1 4 5 3 3 2 3 4 5 4 3 1 5 5 1 5 5 1 Columns 261 through 270 3 4 2 5 3 2 2 2 3 4 4 3 3 3 2 4 4 3 2 1 5 5 2 3 5 4 2 4 3 4 5 5 4 1 4 1 5 5 4 3 3 5 5 5 5 3 5 4 5 3 Columns 271 through 280 1 2 3 5 2 1 5 3 5 5 5 3 4 1 2 4 3 1 2 1 2 3 5 1 1 5 3 5 4 2 2 2 4 1 3 5 2 1 5 5 2 2 3 1 1 3 3 3 5 3 Columns 281 through 290 3 3 4 3 2 3 1 2 4 4 4 3 2 4 3 4 2 5 3 3 5 5 3 3 2 5 3 1 2 1 3 4 3 5 4 4 3 5 3 1 2 4 1 4 4 4 1 1 1 1 Columns 291 through 300 1 5 1 5 3 3 5 3 5 3 3 1 3 5 3 1 4 4 3 5 5 5 1 3 4 5 3 2 1 3 4 1 4 2 1 3 5 2 3 2 3 3 5 1 4 3 3 3 2 2 Columns 301 through 310 1 2 2 2 1 2 1 3 4 ...

2   Pass
%% code = fileread('counter.m'); assert(isempty(strfind(code, 'persistent')));