Given a whole number, output how many segments would be lit up to display it on a 7 segment LED display (see Wikipedia: http://en.wikipedia.org/wiki/Seven-segment_display)
1 -> 2
34 -> 9
Additional test cases have been added.
How to pass test 15, I see only integer converted to float in my function, then back to the int64 is too late, I have lost last digit.
In addition to the remark of TurqoiseInt, y_correct seems to be wrong for test 15. I guess y_correct = 86 assumes x = 12345678987654000.
Test 15 is wrong. True number of segment in number 12345678987654321 is 80. If last digit is losted then true number become 84. In this test correct answer is 86. Maybe it is misprint?
Times 2 - START HERE
Return the 3n+1 sequence for n
Return the first and last character of a string
Length of the hypotenuse
Find a Pythagorean triple
Back to basics 1 - Saving
Back to basics 4 - Search Path
Back to basics 15 - Benchmark
Back to basics 24 - Symbolic variables
Better bullseye matrix
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office