Connection Status:
Competition Arena > UnclearNotes
TCO17 Pittsburgh · 2017-03-31 · by boba5551 · Simple Search, Iteration
Class Name: UnclearNotes
Return Type: String
Method Name: isMatch
Arg Types: (string, string)
Problem Statement

Problem Statement

Anavi is a high-school student. Recently, his teacher wrote a string of lowercase letters and digits onto a whiteboard and Anavi copied the string into his notes.

Anavi has some problems deciphering his teacher's writing. There are three pairs of characters he sometimes gets mixed up:

  • the letter 'o' and the digit '0'
  • the letter 'l' and the digit '1'
  • the letters 'm' and 'n'
For example, this means that some of the '0's in Anavi's notes may have originally been 'o's and vice versa. Anavi is sure that he has copied all other characters correctly.

You are given a String S containing the string Anavi wrote down. You are also given a String T. Return "Possible" if the teacher could have written the string T onto the whiteboard. Otherwise, return "Impossible". (Note that the return value is case-sensitive.)

Constraints

  • Each character of S will be a lowercase English letter ('a'-'z') or a digit ('0'-'9').
  • Each character of T will be a lowercase English letter ('a'-'z') or a digit ('0'-'9').
  • The length of S will be between 1 and 50 characters, inclusive.
  • T and S will be of the same length.
Examples
0)
"topc0der"
"topcoder"
Returns: "Possible"

Anavi wrote down S = "topc0der". As he gets 'o' and '0' mixed up, we know that the whiteboard could have contained any one of the strings "topc0der", "t0pc0der", "t0pcoder", or "topcoder". Since T is among these strings, it is possible that it was written on the whiteboard.

1)
"topcoder"
"codertop"
Returns: "Impossible"

The first letter of S is 't'. Anavi always copies everything correctly, except for the three pairs of characters mentioned in the problem statement. Thus, the first letter of the string on the whiteboard must have been 't' as well. However, the first letter of T is 'c', which means that T cannot be the string from the whiteboard.

2)
"o0ol1lnmn"
"oo0ll1nnm"
Returns: "Possible"

Note that Anavi does not always make mistakes when copying the letters he gets mixed up. For instance, he can copy some of the 'o's correctly, while changing the others into '0's.

3)
"c01unn"
"column"
Returns: "Possible"
4)
"0"
"l"
Returns: "Impossible"

Each pair of characters Anavi gets mixed up is independent. For example, he will only change a '0' into an 'o', he will never change a '0' into an 'l'.

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

Coding Area

Language: C++17 · define a public class UnclearNotes with a public method string isMatch(string S, string T) · 56 test cases · 2 s / 256 MB per case

Submitting as anonymous