Problem:
Input is in form of FNAME LNAME AGE, where FNAME and LNAME are uppercase and AGE is numerical.
Secret code is a string which contains first letter of FNAME, first 4 letters of LNAME and reverse of age.
It is guaranteed that LNAME have length atleast 4
Secret code is a string which contains first letter of FNAME, first 4 letters of LNAME and reverse of age.
It is guaranteed that LNAME have length atleast 4
Input Format:
FNAME LNAME AGE
Output Format:
SECRET NAMEConstraints:
NoneSample Input
PRIYANKA CHOPRA 31
Sample Output:
PCHOP13
Explanations:
P-CHOP-13
Solution:
$str=~ /([A-Z])[A-Z]+\s([A-Z]{4})[A-z]+\s(\d+)/;
print $1.$2.reverse($3);
Tips:
{4}used to capture 4 characters
No comments:
Post a Comment