Cody

# Problem 1477. Champernowne Constant

Solution 2087598

Submitted on 10 Jan 2020 by Asif Newaz
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
x = [1 2 3 4 5]; y_correct = [1 2 3 4 5]; assert(isequal(gendigit_champernowne(x),y_correct))

2   Pass
x = [10 11 12 13 14 15]; y_correct = [1 0 1 1 1 2]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 10 c = 1 d = '10' vy = 1 b = 10 c = 0 d = '10' vy = 1 0 b = 11 c = 1 d = '11' vy = 1 0 1 b = 11 c = 0 d = '11' vy = 1 0 1 1 b = 12 c = 1 d = '12' vy = 1 0 1 1 1 b = 12 c = 0 d = '12' vy = 1 0 1 1 1 2

3   Pass
x = [188 189]; y_correct = [9 9]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 99 c = 1 d = '99' vy = 9 b = 99 c = 0 d = '99' vy = 9 9

4   Pass
x = 2887:3000; y_correct = '999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102'; assert(isequal(sprintf('%d',gendigit_champernowne(2887:3000)),y_correct))

b = 998 c = 2 d = '998' vy = 9 b = 999 c = 1 d = '999' vy = 9 9 b = 999 c = 0 d = '999' vy = 9 9 9 b = 1000 c = 3 d = '1000' vy = 9 9 9 1 b = 1000 c = 2 d = '1000' vy = 9 9 9 1 0 b = 1000 c = 1 d = '1000' vy = 9 9 9 1 0 0 b = 1000 c = 0 d = '1000' vy = 9 9 9 1 0 0 0 b = 1000 c = 3 d = '1000' vy = 9 9 9 1 0 0 0 1 b = 1001 c = 2 d = '1001' vy = 9 9 9 1 0 0 0 1 0 b = 1001 c = 1 d = '1001' vy = 9 9 9 1 0 0 0 1 0 0 b = 1001 c = 0 d = '1001' vy = 9 9 9 1 0 0 0 1 0 0 1 b = 1001 c = 3 d = '1001' vy = 9 9 9 1 0 0 0 1 0 0 1 1 b = 1002 c = 2 d = '1002' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 b = 1002 c = 1 d = '1002' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 b = 1002 c = 0 d = '1002' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 b = 1002 c = 3 d = '1002' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 b = 1003 c = 2 d = '1003' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 b = 1003 c = 1 d = '1003' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 b = 1003 c = 0 d = '1003' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 b = 1003 c = 3 d = '1003' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 b = 1004 c = 2 d = '1004' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 b = 1004 c = 1 d = '1004' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 b = 1004 c = 0 d = '1004' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 b = 1004 c = 3 d = '1004' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 b = 1005 c = 2 d = '1005' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 b = 1005 c = 1 d = '1005' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 b = 1005 c = 0 d = '1005' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 b = 1005 c = 3 d = '1005' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 b = 1006 c = 2 d = '1006' vy = 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 b = 1006 c = 1 d = '1006' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Column 30 0 b = 1006 c = 0 d = '1006' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 31 0 6 b = 1006 c = 3 d = '1006' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 32 0 6 1 b = 1007 c = 2 d = '1007' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 33 0 6 1 0 b = 1007 c = 1 d = '1007' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 34 0 6 1 0 0 b = 1007 c = 0 d = '1007' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 35 0 6 1 0 0 7 b = 1007 c = 3 d = '1007' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 36 0 6 1 0 0 7 1 b = 1008 c = 2 d = '1008' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 37 0 6 1 0 0 7 1 0 b = 1008 c = 1 d = '1008' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 38 0 6 1 0 0 7 1 0 0 b = 1008 c = 0 d = '1008' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 39 0 6 1 0 0 7 1 0 0 8 b = 1008 c = 3 d = '1008' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 40 0 6 1 0 0 7 1 0 0 8 1 b = 1009 c = 2 d = '1009' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 41 0 6 1 0 0 7 1 0 0 8 1 0 b = 1009 c = 1 d = '1009' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 42 0 6 1 0 0 7 1 0 0 8 1 0 0 b = 1009 c = 0 d = '1009' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 43 0 6 1 0 0 7 1 0 0 8 1 0 0 9 b = 1009 c = 3 d = '1009' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 44 0 6 1 0 0 7 1 0 0 8 1 0 0 9 1 b = 1010 c = 2 d = '1010' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Columns 30 through 45 0 6 1 0 0 7 1 0 0 8 1 0 0 9 1 0 b = 1010 c = 1 d = '1010' vy = Columns 1 through 29 9 9 9 1 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 0 0 4 1 0 0 5 1 0 Co...

5   Pass
x=[1000000 1000001 1000002]; y_correct = [1 8 5]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 185184 c = 5 d = '185184' vy = 1 b = 185184 c = 4 d = '185184' vy = 1 8 b = 185185 c = 3 d = '185185' vy = 1 8 5

6   Pass
x=[12000:12005]; y_correct = [7 7 3 2 7 8]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 3277 c = 1 d = '3277' vy = 7 b = 3277 c = 0 d = '3277' vy = 7 7 b = 3277 c = 3 d = '3277' vy = 7 7 3 b = 3278 c = 2 d = '3278' vy = 7 7 3 2 b = 3278 c = 1 d = '3278' vy = 7 7 3 2 7 b = 3278 c = 0 d = '3278' vy = 7 7 3 2 7 8

7   Pass
x=[10000000 10000001 10000002]; y_correct = [7 3 0]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 1587301 c = 3 d = '1587301' vy = 7 b = 1587301 c = 2 d = '1587301' vy = 7 3 b = 1587301 c = 1 d = '1587301' vy = 7 3 0

8   Pass
x=[120000:120005]; y_correct = [2 6 2 2 2 2]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 26221 c = 4 d = '26221' vy = 2 b = 26221 c = 3 d = '26221' vy = 2 6 b = 26222 c = 2 d = '26222' vy = 2 6 2 b = 26222 c = 1 d = '26222' vy = 2 6 2 2 b = 26222 c = 0 d = '26222' vy = 2 6 2 2 2 b = 26222 c = 4 d = '26222' vy = 2 6 2 2 2 2

9   Pass
x=[1200000:1200005]; y_correct = [ 8 5 1 8 2 1]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 218518 c = 3 d = '218518' vy = 8 b = 218518 c = 2 d = '218518' vy = 8 5 b = 218518 c = 1 d = '218518' vy = 8 5 1 b = 218518 c = 0 d = '218518' vy = 8 5 1 8 b = 218518 c = 5 d = '218518' vy = 8 5 1 8 2 b = 218518 c = 4 d = '218518' vy = 8 5 1 8 2 1

10   Pass
x=[1200004:1200009]; y_correct = [ 2 1 8 5 1 9]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 218518 c = 5 d = '218518' vy = 2 b = 218518 c = 4 d = '218518' vy = 2 1 b = 218519 c = 3 d = '218519' vy = 2 1 8 b = 218519 c = 2 d = '218519' vy = 2 1 8 5 b = 218519 c = 1 d = '218519' vy = 2 1 8 5 1 b = 218519 c = 0 d = '218519' vy = 2 1 8 5 1 9

11   Pass
x=[1200008:1200013]; y_correct = [1 9 2 1 8 5]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 218519 c = 1 d = '218519' vy = 1 b = 218519 c = 0 d = '218519' vy = 1 9 b = 218519 c = 5 d = '218519' vy = 1 9 2 b = 218519 c = 4 d = '218519' vy = 1 9 2 1 b = 218520 c = 3 d = '218520' vy = 1 9 2 1 8 b = 218520 c = 2 d = '218520' vy = 1 9 2 1 8 5

12   Pass
x=[13000008:13000013]; y_correct = [2 0 1 5 8 7]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 2015873 c = 6 d = '2015873' vy = 2 b = 2015873 c = 5 d = '2015873' vy = 2 0 b = 2015873 c = 4 d = '2015873' vy = 2 0 1 b = 2015874 c = 3 d = '2015874' vy = 2 0 1 5 b = 2015874 c = 2 d = '2015874' vy = 2 0 1 5 8 b = 2015874 c = 1 d = '2015874' vy = 2 0 1 5 8 7

13   Pass
x=[14000008:14000013]; y_correct = [ 1 5 8 7 3 1]; assert(isequal(gendigit_champernowne(x),y_correct))

b = 2158730 c = 5 d = '2158730' vy = 1 b = 2158730 c = 4 d = '2158730' vy = 1 5 b = 2158731 c = 3 d = '2158731' vy = 1 5 8 b = 2158731 c = 2 d = '2158731' vy = 1 5 8 7 b = 2158731 c = 1 d = '2158731' vy = 1 5 8 7 3 b = 2158731 c = 0 d = '2158731' vy = 1 5 8 7 3 1