What is the string made of?
Practice
3.5 (76 votes)
Ad Hoc
Basic programming
Easy
Open
Problem
45% Success 20602 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

You are given a string, which contains entirely of decimal digits (0-9). Each digit is made of a certain number of dashes, as shown in the image below. For instance 1 is made of 2 dashes, 8 is made of 7 dashes and so on.

digits made of dashes

You have to write a function that takes this string message as an input and returns a corresponding value in terms of a number. This number is the count of dashes in the string message.

Note:

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 [though the figure shows that 7 consists of 4 dashes but due to minor mistake in the problem please write your solution assuming 7 consists of 3 dashes], 8 consists of 7 dashes, 9 consists of 6 dashes.

Constraints

  • String message will contain at least one digit, but not more than 100
  • Each character in code will be a digit ('0'-'9').

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
18 votes
Tags:
Ad-HocEasyImplementation
Points:20
58 votes
Tags:
Ad-HocAlgorithmsApprovedEasyImplementationOpen
Points:20
26 votes
Tags:
ApprovedBasic ProgrammingEasyOpen