Statistics

Problem Statement for "CheckFunction"

Problem Statement

You are given a String code containing a message composed entirely of decimal digits ('0'-'9'). Each digit consists of some number of dashes (see diagram below). A "check function" of a message is defined as the total number of dashes in the message. Return the value of the check function for the message represented in code.

Definition

Class:
CheckFunction
Method:
newFunction
Parameters:
String
Returns:
int
Method signature:
int newFunction(String code)
(be sure your method is public)

Notes

  • 0 consists of 6 dashes, 1 consists of 2 dashes, 2 consists of 5 dashes, 3 consists of 5 dashes, 4 consists of 4 dashes, 5 consists of 5 dashes, 6 consists of 6 dashes, 7 consists of 3 dashes, 8 consists of 7 dashes, 9 consists of 6 dashes.

Constraints

  • code will contain between 1 and 50 characters, inclusive.
  • Each character in code will be a digit ('0'-'9').

Examples

  1. "13579"

    Returns: 21

    1 consists of 2 dashes; 3 consists of 5 dashes; 5 consists of 5 dashes; 7 consists of 3 dashes; 9 consists of 6 dashes; 2 + 5 + 5 + 3 + 6 = 21.

  2. "02468"

    Returns: 28

  3. "73254370932875002027963295052175"

    Returns: 157

  4. "2353246435754687654"

    Returns: 92

  5. "34643575489887084212769"

    Returns: 115

  6. "0"

    Returns: 6

  7. "1"

    Returns: 2

  8. "2"

    Returns: 5

  9. "3"

    Returns: 5

  10. "4"

    Returns: 4

  11. "5"

    Returns: 5

  12. "6"

    Returns: 6

  13. "7"

    Returns: 3

  14. "8"

    Returns: 7

  15. "9"

    Returns: 6

  16. "9515080998489277"

    Returns: 84

  17. "1942539451265494913611165"

    Returns: 110

  18. "37622277099104172983007602567366869"

    Returns: 175

  19. "60212224871769541350"

    Returns: 92

  20. "030108223646"

    Returns: 63

  21. "478095876900037026220314984081017"

    Returns: 166

  22. "2108683747725"

    Returns: 61

  23. "10441288529354869198195619094317937443200619"

    Returns: 212

  24. "483119658477639619560777844979023827617335766016"

    Returns: 227

  25. "83810615483751"

    Returns: 66

  26. "778802988753926"

    Returns: 81

  27. "53"

    Returns: 10

  28. "2893614031392245"

    Returns: 78

  29. "84146371104390424375831218629960300861"

    Returns: 183

  30. "2302697138164656611687198881836980"

    Returns: 173

  31. "868177"

    Returns: 28

  32. "777290612730"

    Returns: 53

  33. "7676511788124748474651181757184202096907339769"

    Returns: 208

  34. "601582531472216524007"

    Returns: 97

  35. "366994218938"

    Returns: 65

  36. "3100748948612"

    Returns: 63

  37. "76721557738626356571857508165188094092"

    Returns: 185

  38. "132903400115444691632515536971893808"

    Returns: 173

  39. "4777125941350583128962359092203656334726325"

    Returns: 210

  40. "8571"

    Returns: 17

  41. "25912655872764420860852224266"

    Returns: 149

  42. "71568005672353784356509914207965"

    Returns: 159

  43. "6115779242467639901841056926730318525777122470"

    Returns: 209

  44. "85515454576446291092006632796384"

    Returns: 160

  45. "025"

    Returns: 16

  46. "2145"

    Returns: 16


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: