Connection Status:
Competition Arena > Sherlock
TCO19 SRM 747 · 2019-01-09 · by misof · Simple Search, Iteration, String Manipulation
Class Name: Sherlock
Return Type: String
Method Name: isItHim
Arg Types: (string, string)
Problem Statement

Problem Statement

  • Computer, find "BENADRYL CUCUMBERPATCH".
  • Did you mean the actor who played Sherlock, Benedict Cumberbatch?

Benedict Cumberbatch is an actor who is famous not only because of his roles. It is also known that you can misspell his name almost arbitrarily and people (and computers too!) will still recognize him.

In this problem, you are given the name of a person: the Strings firstName and lastName. We say that this name matches Benedict Cumberbatch if it has all properties listed below.

  1. Each name must have at least seven letters.
  2. The first name must start with 'B' and the last name must start with 'C'.
  3. At least three characters of firstName must appear somewhere in the name "BENEDICT".
  4. At least five characters of lastName must appear somewhere in the name "CUMBERBATCH".

In conditions 3 and 4 we count each occurrence of a letter, even if that letter occurs in the given name more times than in the actor's actual name. For example, "BATAXXAT" is a valid first name because three of its characters ('B', 'T', 'T') appear in "BENEDICT".

Return "It is him" if all conditions are satisfied and "It is someone else" if they aren't.

Notes

  • Note that the return value is case-sensitive.

Constraints

  • firstName and lastName will each consist of between 1 and 20 characters, inclusive.
  • Each character in firstName and lastName will be an uppercase English letter ('A'-'Z').
Examples
0)
"BENEDICT"
"CUMBERBATCH"
Returns: "It is him"
1)
"BENADRYL"
"CUCUMBERPATCH"
Returns: "It is him"
2)
"HARSHIT"
"MEHTA"
Returns: "It is someone else"
3)
"BATAXXAT"
"CURMUDGEON"
Returns: "It is him"
4)
"BENEDI"
"CUMBER"
Returns: "It is someone else"

Both names are too short.

5)
"BAXAXAXY"
"CENTRIFUGAL"
Returns: "It is someone else"

The first name has too few characters in common with BENEDICT.

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

Coding Area

Language: C++17 · define a public class Sherlock with a public method string isItHim(string firstName, string lastName) · 125 test cases · 2 s / 256 MB per case

Submitting as anonymous