Cody

Problem 44310. Digit concentration in Champernowne's constant

Solution 1687374

Submitted on 6 Dec 2018 by test test
• Size: 8
• This is the leading solution.
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
d = 1; x = 1; y_correct = 1; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
d = 10; x = 5; y_correct = 0.1000; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
d = 10; x = 1; y_correct = 0.2000; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
d = 20; x = 9; y_correct = 0.0500; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint4 (line 4) In solutionTest (line 9)]

5   Pass
d = 50; x = 0; y_correct = 0.0400; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]

6   Pass
d = 50; x = 2; y_correct = 0.2600; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint6 (line 4) In solutionTest (line 13)]

7   Pass
d = 1000; x = 9; y_correct = 0.0670; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint7 (line 4) In solutionTest (line 15)]

8   Pass
d = 1e4; x = 8; y_correct = 0.0747; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint8 (line 4) In solutionTest (line 17)]

9   Pass
d = 1e5; x = 7; y_correct = 0.0864; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint9 (line 4) In solutionTest (line 19)]

10   Pass
d = 1e6; x = 6; y_correct = 0.0935; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint10 (line 4) In solutionTest (line 21)]

11   Pass
d = 1e6; x = 5; y_correct = 0.0937; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint11 (line 4) In solutionTest (line 23)]

12   Pass
d = 2e6; x = 4; y_correct = 0.0903; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint12 (line 4) In solutionTest (line 25)]

13   Pass
d = 2000124; x = 3; y_correct = 0.1162; assert(abs(digitCon(d,x)-y_correct) < 1e-4)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In digitCon (line 1) In ScoringEngineTestPoint13 (line 4) In solutionTest (line 27)]

Community Treasure Hunt

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

Start Hunting!