Problem
You inherited a piece of code that performs username validation for your company’s website. The existing function works reasonably well, but it throws an exception when the username is too short. Upon review, you realize that nobody ever defined the exception.
The inherited code is provided for you in the locked section of your editor. Complete the code so that, when an exception is thrown, it prints Too short: n (where n is the length of the given username).
Input Format :
The first line contains an integer, t, the number of test cases.
Each of the t subsequent lines describes a test case as a single username string, n.
Constraints :
- 1 <= t <= 1000
- 1<= |u| <= 100
- The username consists only of uppercase and lowercase letters.
Output Format :
You are not responsible for directly printing anything to stdout. If your code is correct, the locked stub code in your editor will print either Valid (if the username is valid), Invalid (if the username is invalid), or Too short: n (where n is the length of the too-short username) on a new line for each test case.
Sample Input :
3
Peter
Me
Arxwwz
Sample Output :
Valid Too short: 2 Invalid
Explanation :
Username Me is too short because it only contains 2 characters, so your exception prints Too Short : 2.
All other validation is handled by the locked code in your editor.
Inherited Code in C++ – Hacker Rank Solution
Tags: hackerrank c++ solutions | Functions Discussions | C++ | HackerRank | student analysis C++ hackerrank solution | challenges C++ hackerrank solution | hackerrank C++ basic certification solutions | hackerrank-C++ certification solutions | basic data types hackerrank solution in c++ | variable sized arrays hackerrank solution in c++ | inherited code hackerrank solution in c++ | hackerrank c++ solutions github | hackerrank data structures solutions in c++ | hackerrank c++ class solution | pointer hackerrank solution in c++ | box it hackerrank solution in c++ | 2021
ConversionConversion EmoticonEmoticon