Cody

Problem 324. 7 segment LED display

Solution 3034687

Submitted on 2 Oct 2020
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; y_correct = 2; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 1 c = 1 e = 2

2   Pass
x = 2; y_correct = 5; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 2 c = 2 e = 5

3   Pass
x = 3; y_correct = 5; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 3 c = 3 e = 5

4   Pass
x = 4; y_correct = 4; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 4 c = 4 e = 4

5   Pass
x = 5; y_correct = 5; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 5 c = 5 e = 5

6   Pass
x = 6; y_correct = 6; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 6 c = 6 e = 6

7   Pass
x = 7; y_correct = 3; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 7 c = 7 e = 3

8   Pass
x = 8; y_correct = 7; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 8 c = 8 e = 7

9   Pass
x = 9; y_correct = 6; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 9 c = 9 e = 6

10   Fail
x = 0; y_correct = 6; assert(isequal(seven_seg_led(x),y_correct))

Assertion failed.

11   Pass
x = 10; y_correct = 8; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 0 c = 0 e = 6 i = 2 d = 1 c = 10 e = 2

12   Pass
x = 42; y_correct = 9; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 2 c = 2 e = 5 i = 2 d = 4 c = 42 e = 4

13   Pass
x = 101010101; y_correct = 34; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 1 c = 1 e = 2 i = 2 d = 0 c = 1 e = 6 i = 3 d = 1 c = 101 e = 2 i = 4 d = 0 c = 101 e = 6 i = 5 d = 1 c = 10101 e = 2 i = 6 d = 0 c = 10101 e = 6 i = 7 d = 1 c = 1010101 e = 2 i = 8 d = 0 c = 1010101 e = 6 i = 9 d = 1 c = 101010101 e = 2

14   Pass
x = 1234567890; y_correct = 49; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 0 c = 0 e = 6 i = 2 d = 9 c = 90 e = 6 i = 3 d = 8 c = 890 e = 7 i = 4 d = 7 c = 7890 e = 3 i = 5 d = 6 c = 67890 e = 6 i = 6 d = 5 c = 567890 e = 5 i = 7 d = 4 c = 4567890 e = 4 i = 8 d = 3 c = 34567890 e = 5 i = 9 d = 2 c = 234567890 e = 5 i = 10 d = 1 c = 1.2346e+09 e = 2

15   Pass
% x = 12345678987654321; % y_correct = 86; % assert(isequal(seven_seg_led(x),y_correct))

16   Pass
x = 222444666888000; y_correct = 84; assert(isequal(seven_seg_led(x),y_correct))

i = 1 d = 0 c = 0 e = 6 i = 2 d = 0 c = 0 e = 6 i = 3 d = 0 c = 0 e = 6 i = 4 d = 8 c = 8000 e = 7 i = 5 d = 8 c = 88000 e = 7 i = 6 d = 8 c = 888000 e = 7 i = 7 d = 6 c = 6888000 e = 6 i = 8 d = 6 c = 66888000 e = 6 i = 9 d = 6 c = 666888000 e = 6 i = 10 d = 4 c = 4.6669e+09 e = 4 i = 11 d = 4 c = 4.4667e+10 e = 4 i = 12 d = 4 c = 4.4467e+11 e = 4 i = 13 d = 2 c = 2.4447e+12 e = 5 i = 14 d = 2 c = 2.2445e+13 e = 5 i = 15 d = 2 c = 2.2244e+14 e = 5

Suggested Problems

More from this Author39

Community Treasure Hunt

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

Start Hunting!