Cody

Problem 1742. Generate a Parasitic Number

Solution 704720

Submitted on 22 Jul 2015 by Tomasz
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
%% n=4;k=7;y_correct='179487'; assert(isequal(generate_parasitic(k,n),y_correct))

y = 1 y = 17 y = 179 y = 1794 y = 17948 y = 179487

2   Pass
%% n=7;k=4;y_correct='0579710144927536231884'; assert(isequal(generate_parasitic(k,n),y_correct))

y = 0 y = 05 y = 057 y = 0579 y = 05797 y = 057971 y = 0579710 y = 05797101 y = 057971014 y = 0579710144 y = 05797101449 y = 057971014492 y = 0579710144927 y = 05797101449275 y = 057971014492753 y = 0579710144927536 y = 05797101449275362 y = 057971014492753623 y = 0579710144927536231 y = 05797101449275362318 y = 057971014492753623188 y = 0579710144927536231884

3   Pass
%% n=2;k=6;y_correct='315789473684210526'; assert(isequal(generate_parasitic(k,n),y_correct))

y = 3 y = 31 y = 315 y = 3157 y = 31578 y = 315789 y = 3157894 y = 31578947 y = 315789473 y = 3157894736 y = 31578947368 y = 315789473684 y = 3157894736842 y = 31578947368421 y = 315789473684210 y = 3157894736842105 y = 31578947368421052 y = 315789473684210526

4   Pass
%% n=5;k=7;y_correct='142857'; assert(isequal(generate_parasitic(k,n),y_correct))

y = 1 y = 14 y = 142 y = 1428 y = 14285 y = 142857

5   Pass
%% n=1;k=3;y_correct='3'; assert(isequal(generate_parasitic(k,n),y_correct))

y = 3

6   Pass
%% n=6;k=6;y_correct='1016949152542372881355932203389830508474576271186440677966' assert(isequal(generate_parasitic(k,n),y_correct))

y_correct = 1016949152542372881355932203389830508474576271186440677966 y = 1 y = 10 y = 101 y = 1016 y = 10169 y = 101694 y = 1016949 y = 10169491 y = 101694915 y = 1016949152 y = 10169491525 y = 101694915254 y = 1016949152542 y = 10169491525423 y = 101694915254237 y = 1016949152542372 y = 10169491525423728 y = 101694915254237288 y = 1016949152542372881 y = 10169491525423728813 y = 101694915254237288135 y = 1016949152542372881355 y = 10169491525423728813559 y = 101694915254237288135593 y = 1016949152542372881355932 y = 10169491525423728813559322 y = 101694915254237288135593220 y = 1016949152542372881355932203 y = 10169491525423728813559322033 y = 101694915254237288135593220338 y = 1016949152542372881355932203389 y = 10169491525423728813559322033898 y = 101694915254237288135593220338983 y = 1016949152542372881355932203389830 y = 10169491525423728813559322033898305 y = 101694915254237288135593220338983050 y = 1016949152542372881355932203389830508 y = 10169491525423728813559322033898305084 y = 101694915254237288135593220338983050847 y = 1016949152542372881355932203389830508474 y = 10169491525423728813559322033898305084745 y = 101694915254237288135593220338983050847457 y = 1016949152542372881355932203389830508474576 y = 10169491525423728813559322033898305084745762 y = 101694915254237288135593220338983050847457627 y = 1016949152542372881355932203389830508474576271 y = 10169491525423728813559322033898305084745762711 y = 101694915254237288135593220338983050847457627118 y = 1016949152542372881355932203389830508474576271186 y = 10169491525423728813559322033898305084745762711864 y = 101694915254237288135593220338983050847457627118644 y = 1016949152542372881355932203389830508474576271186440 y = 10169491525423728813559322033898305084745762711864406 y = 101694915254237288135593220338983050847457627118644067 y = 1016949152542372881355932203389830508474576271186440677 y = 10169491525423728813559322033898305084745762711864406779 y = 101694915254237288135593220338983050847457627118644067796 y = 1016949152542372881355932203389830508474576271186440677966

7   Pass
%% n=9;k=6;y_correct='06741573033707865168539325842696629213483146' assert(isequal(generate_parasitic(k,n),y_correct))

y_correct = 06741573033707865168539325842696629213483146 y = 0 y = 06 y = 067 y = 0674 y = 06741 y = 067415 y = 0674157 y = 06741573 y = 067415730 y = 0674157303 y = 06741573033 y = 067415730337 y = 0674157303370 y = 06741573033707 y = 067415730337078 y = 0674157303370786 y = 06741573033707865 y = 067415730337078651 y = 0674157303370786516 y = 06741573033707865168 y = 067415730337078651685 y = 0674157303370786516853 y = 06741573033707865168539 y = 067415730337078651685393 y = 0674157303370786516853932 y = 06741573033707865168539325 y = 067415730337078651685393258 y = 0674157303370786516853932584 y = 06741573033707865168539325842 y = 067415730337078651685393258426 y = 0674157303370786516853932584269 y = 06741573033707865168539325842696 y = 067415730337078651685393258426966 y = 0674157303370786516853932584269662 y = 06741573033707865168539325842696629 y = 067415730337078651685393258426966292 y = 0674157303370786516853932584269662921 y = 06741573033707865168539325842696629213 y = 067415730337078651685393258426966292134 y = 0674157303370786516853932584269662921348 y = 06741573033707865168539325842696629213483 y = 067415730337078651685393258426966292134831 y = 0674157303370786516853932584269662921348314 y = 06741573033707865168539325842696629213483146