TLE '17 Contest 1 P1 - String Rounding

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type
An inhabitant of TR-387 is giving a number to Fax.

Fax McClad, Croneria's most adventurous bounty hunter, has been tasked to explore the unknown planet TR-387. Upon arrival to this planet, he finds a primitive civilization of alien beings. He is surprised to learn that they only use lowercase English letters to represent digits in their number system!

The beings of this planet are particularly fond of a technique called rounding. Here are the rules on how to round a number:

  • Start with the last (rightmost) digit of the number.
  • If the digit is in between a and m, set the digit to a.
  • If the digit is in between n and z, set the digit to a and increase the next (left) digit by one character. If the next digit happens to be z, round that character instead of increasing it. If there is no next digit, add a to the left of the number.

Fax wishes to be acquainted with this alien species by showing them that he knows their rounding technique, but he is having difficulty doing so. Given a number S, can you round it for him?

Input Specification

The first and only line of input will contain S, a string consisting only of lowercase English letters. S will contain at least 1 character and at most 100 characters.

Output Specification

Output one line, the rounded value of S.

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2


Sample Input 3


Sample Output 3



  • 0
    echofox  commented on April 26, 2018, 9:27 p.m.

    ayy lmao