CryptoDigit
SRM 118 · 2002-10-29 · by dgoodman
Problem Statement
Create a class CryptoDigit that
contains the method add that takes a
Notes
- mapping will contain the 10 mapped characters corresponding to our '0','1',...,'9' in that order.
- The returned String should not have superfluous leading mapped zeroes (see Example 0).
- num1 and num2 may contain leading mapped zeroes.
Constraints
- mapping contains exactly 10 characters, all distinct
- mapping contains only lowercase letters a-z and digits 0-9
- num1 and num2 contain only characters that appear in mapping
- num1 contains between 1 and 9 characters, inclusive.
- num2 contains between 1 and 9 characters, inclusive.
"0123456789" "91" "0009" Returns: "100"
This is the identity mapping.
"9876543210" "91" "0009" Returns: "0001"
num1 is what we call "8" and num2 is what we call "9990", so their sum is what we call "9998" which is 0001 under the mapping.
"abcdefghij" "jjjjjjjjj" "jjjjjjjjj" Returns: "bjjjjjjjji"
"abcdefghij" "a" "aaaab" Returns: "b"
"abcdefghij" "j" "b" Returns: "ba"
"ab7defg9i2" "aa" "aaa" Returns: "a"
This leading mapped zero is necessary.
Submissions are judged against all 13 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CryptoDigit with a public method string add(string mapping, string num1, string num2) · 13 test cases · 2 s / 256 MB per case