Cody

Problem 1477. Champernowne Constant

Solution 2269763

Submitted on 11 May 2020 by NMTri
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))

n_sub = 1 n_sub = 2 n_sub = 3 n_sub = 4 n_sub = 5 n_sub = 6

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

n_sub = 179 n_sub = 180

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

n_sub = 2698 n_sub = 2699 n_sub = 2700 n_sub = 1 n_sub = 2 n_sub = 3 n_sub = 4 n_sub = 5 n_sub = 6 n_sub = 7 n_sub = 8 n_sub = 9 n_sub = 10 n_sub = 11 n_sub = 12 n_sub = 13 n_sub = 14 n_sub = 15 n_sub = 16 n_sub = 17 n_sub = 18 n_sub = 19 n_sub = 20 n_sub = 21 n_sub = 22 n_sub = 23 n_sub = 24 n_sub = 25 n_sub = 26 n_sub = 27 n_sub = 28 n_sub = 29 n_sub = 30 n_sub = 31 n_sub = 32 n_sub = 33 n_sub = 34 n_sub = 35 n_sub = 36 n_sub = 37 n_sub = 38 n_sub = 39 n_sub = 40 n_sub = 41 n_sub = 42 n_sub = 43 n_sub = 44 n_sub = 45 n_sub = 46 n_sub = 47 n_sub = 48 n_sub = 49 n_sub = 50 n_sub = 51 n_sub = 52 n_sub = 53 n_sub = 54 n_sub = 55 n_sub = 56 n_sub = 57 n_sub = 58 n_sub = 59 n_sub = 60 n_sub = 61 n_sub = 62 n_sub = 63 n_sub = 64 n_sub = 65 n_sub = 66 n_sub = 67 n_sub = 68 n_sub = 69 n_sub = 70 n_sub = 71 n_sub = 72 n_sub = 73 n_sub = 74 n_sub = 75 n_sub = 76 n_sub = 77 n_sub = 78 n_sub = 79 n_sub = 80 n_sub = 81 n_sub = 82 n_sub = 83 n_sub = 84 n_sub = 85 n_sub = 86 n_sub = 87 n_sub = 88 n_sub = 89 n_sub = 90 n_sub = 91 n_sub = 92 n_sub = 93 n_sub = 94 n_sub = 95 n_sub = 96 n_sub = 97 n_sub = 98 n_sub = 99 n_sub = 100 n_sub = 101 n_sub = 102 n_sub = 103 n_sub = 104 n_sub = 105 n_sub = 106 n_sub = 107 n_sub = 108 n_sub = 109 n_sub = 110 n_sub = 111

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

n_sub = 511111 n_sub = 511112 n_sub = 511113

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

n_sub = 9111 n_sub = 9112 n_sub = 9113 n_sub = 9114 n_sub = 9115 n_sub = 9116

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

n_sub = 4111111 n_sub = 4111112 n_sub = 4111113

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

n_sub = 81111 n_sub = 81112 n_sub = 81113 n_sub = 81114 n_sub = 81115 n_sub = 81116

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

n_sub = 711111 n_sub = 711112 n_sub = 711113 n_sub = 711114 n_sub = 711115 n_sub = 711116

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

n_sub = 711115 n_sub = 711116 n_sub = 711117 n_sub = 711118 n_sub = 711119 n_sub = 711120

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

n_sub = 711119 n_sub = 711120 n_sub = 711121 n_sub = 711122 n_sub = 711123 n_sub = 711124

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

n_sub = 7111119 n_sub = 7111120 n_sub = 7111121 n_sub = 7111122 n_sub = 7111123 n_sub = 7111124

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

n_sub = 8111119 n_sub = 8111120 n_sub = 8111121 n_sub = 8111122 n_sub = 8111123 n_sub = 8111124

Suggested Problems

More from this Author10

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!