Statistics

Problem Statement for "LitLCD"

Problem Statement

Given an int, how many LCD lines would show up on an old 8-digit calculator to represent the int?

Below are 10 digits and 'e' and '-' commonly used to display numbers on a calculator.

 _      _  _       _   _  _   _   _     _
| |  |  _| _| |_| |_  |_   | |_| |_|   |_   _
|_|  | |_  _|   |  _| |_|  | |_|  _|   |_

'0' has 6 lines, '1' has 2 lines, '2' has 5 lines
'3' has 5 lines, '4' has 4 lines, '5' has 5 lines
'6' has 6 lines, '7' has 3 lines, '8' has 7 lines
'9' has 6 lines, 'e' has 5 lines, and '-' has 1 line

The calculator only has 8 digits, and '-' takes up one of them: it can display "-1234567" or "12345678" but not "-12345678". If the number is too big to fit on the display, the calculator will display the error "0E" (consisting of 11 lines).

The calculator will never show leading 0s. For example, 1 will always show as '1', not as '000001', and 0 will show as '0' not as '00'. The calculator will never show '-0'. 0 will always show as '0' (6 lines).

Definition

Class:
LitLCD
Method:
numLines
Parameters:
int
Returns:
int
Method signature:
int numLines(int numToDisplay)
(be sure your method is public)

Notes

  • if the number is out of range for the calculator, you should return 11 (the number of LCD lines in 0E).

Constraints

  • numToDisplay will be between -999,999,999 to 999,999,999, inclusive

Examples

  1. 17

    Returns: 5

  2. 11118888

    Returns: 36

  3. 99999999

    Returns: 48

  4. 88888888

    Returns: 56

  5. 100000000

    Returns: 11

  6. 12345678

    Returns: 37

  7. 12345678

    Returns: 37

  8. -1024

    Returns: 18

  9. 4444

    Returns: 16

  10. 111

    Returns: 6

  11. 7171171

    Returns: 17

  12. 654345

    Returns: 29

  13. 98675

    Returns: 27

  14. 55555

    Returns: 25

  15. 333

    Returns: 15

  16. -7413759

    Returns: 29

  17. -12034102

    Returns: 11

  18. 123484937

    Returns: 11

  19. 8178234

    Returns: 33

  20. 3467355

    Returns: 33

  21. -9231999

    Returns: 37

  22. 999999997

    Returns: 11

  23. -1

    Returns: 3

  24. 0

    Returns: 6

  25. -9999999

    Returns: 43

  26. -12345678

    Returns: 11

  27. 999

    Returns: 18

  28. 7

    Returns: 3

  29. 999999999

    Returns: 11

  30. 111111111

    Returns: 11

  31. 42

    Returns: 9

  32. 77777777

    Returns: 24

  33. -99999999

    Returns: 11

  34. -999999998

    Returns: 11

  35. -1234567

    Returns: 31

  36. -10000000

    Returns: 11

  37. -999999999

    Returns: 11

  38. -99999998

    Returns: 11

  39. -88888888

    Returns: 11

  40. 12345679

    Returns: 36

  41. 9999

    Returns: 24

  42. -7654321

    Returns: 31

  43. 888

    Returns: 21

  44. 546456

    Returns: 30

  45. 1024

    Returns: 17

    _ _ | | | _| |_| | |_| |_ | 2 for '1', 6 for '0', 5 for '2', 4 for '4'

  46. -1024

    Returns: 18

  47. 12345678

    Returns: 37

  48. -999999999

    Returns: 11

  49. 0

    Returns: 6

  50. 111

    Returns: 6

  51. 99999999

    Returns: 48

  52. 100000000

    Returns: 11


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: