Cody

Solution 664998

Submitted on 3 May 2015 by Richard Zapor
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
tic

2   Pass
%% N=1; L=Counter_Culture(N); Lexp=1; assert(isequal(Lexp,L))

3   Pass
%% N=19; L=Counter_Culture(N); Lexp=19; assert(isequal(Lexp,L))

4   Pass
%% N=23; L=Counter_Culture(N); Lexp=15; assert(isequal(Lexp,L))

5   Pass
%% N=1101; L=Counter_Culture(N); Lexp=150; assert(isequal(Lexp,L))

6   Pass
%% N=998999; L=Counter_Culture(N); Lexp=3334; assert(isequal(Lexp,L))

7   Pass
%% N=990000; L=Counter_Culture(N); Lexp=3425; assert(isequal(Lexp,L))

8   Pass
%% N=10110; L=Counter_Culture(N); Lexp=447; assert(isequal(Lexp,L))

9   Pass
%% N=11111; L=Counter_Culture(N); Lexp=459; assert(isequal(Lexp,L))

10   Pass
%% N=999991; L=Counter_Culture(N); Lexp=3426; assert(isequal(Lexp,L))

11   Pass
%% N=512; L=Counter_Culture(N); Lexp=46; assert(isequal(Lexp,L))

12   Pass
%% N=999899; L=Counter_Culture(N); Lexp=3334; assert(isequal(Lexp,L))

13   Pass
%% N=1999; L=Counter_Culture(N); Lexp=328; assert(isequal(Lexp,L))

14   Pass
%% N=11101; L=Counter_Culture(N); Lexp=449; assert(isequal(Lexp,L))

15   Pass
%% N=876543; L=Counter_Culture(N); Lexp=2657; assert(isequal(Lexp,L))

16   Pass
%% N=4; L=Counter_Culture(N); Lexp=4; assert(isequal(Lexp,L))

17   Pass
%% N=102; L=Counter_Culture(N); Lexp=31; assert(isequal(Lexp,L))

18   Pass
%% N=11000; L=Counter_Culture(N); Lexp=1337; assert(isequal(Lexp,L))

19   Pass
%% N=1998; L=Counter_Culture(N); Lexp=327; assert(isequal(Lexp,L))

20   Pass
%% N=900000; L=Counter_Culture(N); Lexp=3434; assert(isequal(Lexp,L))

21   Pass
%% N=131072; L=Counter_Culture(N); Lexp=1639; assert(isequal(Lexp,L))

22   Pass
%% N=524288; L=Counter_Culture(N); Lexp=2149; assert(isequal(Lexp,L))

23   Pass
%% N=20; L=Counter_Culture(N); Lexp=20; assert(isequal(Lexp,L))

24   Pass
%% N=789012; L=Counter_Culture(N); Lexp=2435; assert(isequal(Lexp,L))

25   Pass
%% N=200; L=Counter_Culture(N); Lexp=129; assert(isequal(Lexp,L))

26   Pass
%% N=109876; L=Counter_Culture(N); Lexp=3213; assert(isequal(Lexp,L))

27   Pass
%% N=11100; L=Counter_Culture(N); Lexp=448; assert(isequal(Lexp,L))

28   Pass
%% N=262144; L=Counter_Culture(N); Lexp=1842; assert(isequal(Lexp,L))

29   Pass
%% N=11; L=Counter_Culture(N); Lexp=11; assert(isequal(Lexp,L))

30   Pass
%% N=1001; L=Counter_Culture(N); Lexp=139; assert(isequal(Lexp,L))

31   Pass
%% N=987654; L=Counter_Culture(N); Lexp=2879; assert(isequal(Lexp,L))

32   Pass
%% N=999989; L=Counter_Culture(N); Lexp=3424; assert(isequal(Lexp,L))

33   Pass
%% N=11011; L=Counter_Culture(N); Lexp=359; assert(isequal(Lexp,L))

34   Pass
%% N=4096; L=Counter_Culture(N); Lexp=238; assert(isequal(Lexp,L))

35   Pass
%% N=900001; L=Counter_Culture(N); Lexp=1446; assert(isequal(Lexp,L))

36   Pass
%% N=201; L=Counter_Culture(N); Lexp=32; assert(isequal(Lexp,L))

37   Pass
%% N=99001; L=Counter_Culture(N); Lexp=437; assert(isequal(Lexp,L))

38   Pass
%% N=999999; L=Counter_Culture(N); Lexp=3434; assert(isequal(Lexp,L))

39   Pass
%% N=999900; L=Counter_Culture(N); Lexp=3335; assert(isequal(Lexp,L))

40   Pass
%% N=901; L=Counter_Culture(N); Lexp=39; assert(isequal(Lexp,L))

41   Pass
%% N=2201; L=Counter_Culture(N); Lexp=161; assert(isequal(Lexp,L))

42   Pass
%% N=90; L=Counter_Culture(N); Lexp=28; assert(isequal(Lexp,L))

43   Pass
%% N=101; L=Counter_Culture(N); Lexp=30; assert(isequal(Lexp,L))

44   Pass
%% N=10111; L=Counter_Culture(N); Lexp=448; assert(isequal(Lexp,L))

45   Pass
%% N=31; L=Counter_Culture(N); Lexp=14; assert(isequal(Lexp,L))

46   Pass
%% N=10; L=Counter_Culture(N); Lexp=10; assert(isequal(Lexp,L))

47   Pass
%% N=10100; L=Counter_Culture(N); Lexp=437; assert(isequal(Lexp,L))

48   Pass
%% N=999998; L=Counter_Culture(N); Lexp=3433; assert(isequal(Lexp,L))

49   Pass
%% N=999000; L=Counter_Culture(N); Lexp=3335; assert(isequal(Lexp,L))

50   Pass
%% N=990001; L=Counter_Culture(N); Lexp=1536; assert(isequal(Lexp,L))

51   Pass
%% N=30; L=Counter_Culture(N); Lexp=22; assert(isequal(Lexp,L))

52   Pass
%% N=900; L=Counter_Culture(N); Lexp=137; assert(isequal(Lexp,L))

53   Pass
%% N=101001; L=Counter_Culture(N); Lexp=1538; assert(isequal(Lexp,L))

54   Pass
%% N=999990; L=Counter_Culture(N); Lexp=3425; assert(isequal(Lexp,L))

55   Pass
%% N=989999; L=Counter_Culture(N); Lexp=3424; assert(isequal(Lexp,L))

56   Pass
%% N=21; L=Counter_Culture(N); Lexp=13; assert(isequal(Lexp,L))

57   Pass
%% N=9999; L=Counter_Culture(N); Lexp=336; assert(isequal(Lexp,L))

58   Pass
%% N=100001; L=Counter_Culture(N); Lexp=1437; assert(isequal(Lexp,L))

59   Pass
%% N=10999; L=Counter_Culture(N); Lexp=1336; assert(isequal(Lexp,L))

60   Pass
%% N=100; L=Counter_Culture(N); Lexp=29; assert(isequal(Lexp,L))

61   Pass
%% N=91; L=Counter_Culture(N); Lexp=20; assert(isequal(Lexp,L))

62   Pass
%% N=11010; L=Counter_Culture(N); Lexp=358; assert(isequal(Lexp,L))

63   Pass
%% N=29; L=Counter_Culture(N); Lexp=21; assert(isequal(Lexp,L))

64   Pass
%% N=2001; L=Counter_Culture(N); Lexp=141; assert(isequal(Lexp,L))

65   Pass
%% N=11110; L=Counter_Culture(N); Lexp=458; assert(isequal(Lexp,L))

66   Pass
%% N=10001; L=Counter_Culture(N); Lexp=338; assert(isequal(Lexp,L))

67   Pass
%% N=9; L=Counter_Culture(N); Lexp=9; assert(isequal(Lexp,L))

68   Pass
%% N=101000; L=Counter_Culture(N); Lexp=2436; assert(isequal(Lexp,L))

69   Pass
%% N=1000; L=Counter_Culture(N); Lexp=138; assert(isequal(Lexp,L))

70   Pass
%% N=19; L=Counter_Culture(N); Lexp=19; assert(isequal(Lexp,L))

71   Pass
%% N=12000; L=Counter_Culture(N); Lexp=1348; assert(isequal(Lexp,L))

72   Pass
%% N=999; L=Counter_Culture(N); Lexp=137; assert(isequal(Lexp,L))

73   Pass
%% N=22; L=Counter_Culture(N); Lexp=14; assert(isequal(Lexp,L))

74   Pass
%% N=1111; L=Counter_Culture(N); Lexp=160; assert(isequal(Lexp,L))

75   Pass
%% N=12001; L=Counter_Culture(N); Lexp=359; assert(isequal(Lexp,L))

76   Pass
%% N=12; L=Counter_Culture(N); Lexp=12; assert(isequal(Lexp,L))

77   Pass
%% N=99000; L=Counter_Culture(N); Lexp=1426; assert(isequal(Lexp,L))

78   Pass
%% N=999001; L=Counter_Culture(N); Lexp=2436; assert(isequal(Lexp,L))

79   Pass
%% N=899999; L=Counter_Culture(N); Lexp=3433; assert(isequal(Lexp,L))

80   Pass
%% N=10010; L=Counter_Culture(N); Lexp=347; assert(isequal(Lexp,L))

81   Pass
%% N=10000; L=Counter_Culture(N); Lexp=337; assert(isequal(Lexp,L))

82   Pass
%% N=10101; L=Counter_Culture(N); Lexp=438; assert(isequal(Lexp,L))

83   Pass
%% N=2000; L=Counter_Culture(N); Lexp=329; assert(isequal(Lexp,L))

84   Pass
%% N=111; L=Counter_Culture(N); Lexp=40; assert(isequal(Lexp,L))

85   Pass
%% N=999901; L=Counter_Culture(N); Lexp=3336; assert(isequal(Lexp,L))

86   Pass
%% N=2101; L=Counter_Culture(N); Lexp=151; assert(isequal(Lexp,L))

87   Pass
%% N=10011; L=Counter_Culture(N); Lexp=348; assert(isequal(Lexp,L))

88   Pass
%% N=2002; L=Counter_Culture(N); Lexp=142; assert(isequal(Lexp,L))

89   Pass
%% N=32; L=Counter_Culture(N); Lexp=15; assert(isequal(Lexp,L))

90   Pass
%% N=110; L=Counter_Culture(N); Lexp=39; assert(isequal(Lexp,L))

91   Pass
%% N=2100; L=Counter_Culture(N); Lexp=240; assert(isequal(Lexp,L))

92   Pass
%% N=11001; L=Counter_Culture(N); Lexp=349; assert(isequal(Lexp,L))

93   Pass
%% N=99; L=Counter_Culture(N); Lexp=28; assert(isequal(Lexp,L))

94   Pass
%% N=1100; L=Counter_Culture(N); Lexp=238; assert(isequal(Lexp,L))

95   Pass
%% N=1099; L=Counter_Culture(N); Lexp=237; assert(isequal(Lexp,L))

96   Pass
%% N=1000000; L=Counter_Culture(N); Lexp=3435; assert(isequal(Lexp,L))

97   Pass
%% N=100000; L=Counter_Culture(N); Lexp=1436; assert(isequal(Lexp,L))

98   Pass
%% N=2200; L=Counter_Culture(N); Lexp=250; assert(isequal(Lexp,L))

99   Pass
%% N=1110; L=Counter_Culture(N); Lexp=159; assert(isequal(Lexp,L))

100   Pass
%% N=432109; L=Counter_Culture(N); Lexp=1779; assert(isequal(Lexp,L))

101   Pass
%% N=199; L=Counter_Culture(N); Lexp=128; assert(isequal(Lexp,L))

102   Pass
%% toc

Elapsed time is 1.034039 seconds.

103   Pass
%% % function GJam_Rd1B_2015a % % % fn='A-small-practice.in'; % [data] = read_file(fn); % % % fidG = fopen('A-small-practice.out', 'w'); % % tic % for i=1:size(data,2) % Cell array has J cols of cases % L = Counter_Culture(data{i}); % fprintf(fidG,'Case #%i: %i\n',i,L); % fprintf('Case #%i: %i\n',i,L); % end % toc % fclose(fidG); % end % % function depth=Counter_Culture(v) % % create all paths % persistent m mv maxdepth % if isempty(m) % % mv=zeros(1000000,1); % m{1000000}=[]; % set cell array size to max possible % for i=1:9 % m{i}=i; % mv(i)=i; % place best depth into mv for repeated searches % end % maxdepth=9; % end % % if mv(v) % usage of persistent data % depth=mv(v); % return; % end % % % while 1 % mset=m{maxdepth}; % start with last set calculated % maxdepth=maxdepth+1; % msetn=mset+1; % % msetn=msetn(mv(msetn)==0); % mv(msetn)=maxdepth; % % for i=1:length(mset) % flipv=calc_flip(mset(i)); % if mv(flipv)==0 % new value % mv(flipv)=maxdepth; % msetn=[msetn flipv]; % add to list % end % end % % m{maxdepth}=msetn; % % if any(msetn==v) % depth=maxdepth; % return % end % % end % while % % end % % function vr=calc_flip(val) % vr=0; % while val % v1=mod(val,10); % vr=10*vr+v1; % val=(val-v1)/10; % end % end % % function [d] = read_file(fn) % d={}; % fid=fopen(fn); % fgetl(fid); % Total Count ignore % ptr=0; % while ~feof(fid) % ptr=ptr+1; % v=str2num(fgetl(fid)); % d{ptr}=v; % end % feof % fclose(fid); % end % read_file

104   Pass
%% toc

Elapsed time is 1.054639 seconds.