Connection Status:
Competition Arena > CheckFunction
SRM 271 · 2005-11-08 · by Vedensky · Brute Force
Class Name: CheckFunction
Return Type: int
Method Name: newFunction
Arg Types: (string)
Problem Statement

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.

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
0)
"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.

1)
"02468"
Returns: 28
2)
"73254370932875002027963295052175"
Returns: 157
3)
"2353246435754687654"
Returns: 92
4)
"34643575489887084212769"
Returns: 115

Submissions are judged against all 46 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class CheckFunction with a public method int newFunction(string code) · 46 test cases · 2 s / 256 MB per case

Submitting as anonymous