#K95432. Pig Latin Translator

    ID: 38862 Type: Default 1000ms 256MiB

Pig Latin Translator

Pig Latin Translator

Given a sentence, transform each word into Pig Latin by moving its first letter to the end followed by ay. Punctuation marks should remain in their original positions, and multiple spaces must be preserved.

Rules:

  • If the word consists entirely of letters, the transformation is: $$word = word[1:] + word[0] + \text{ay}$$.
  • If the word contains punctuation, treat the alphabetic characters as the word and keep the punctuation in place. For example, Hi, becomes iHay,.
  • If the word contains only punctuation, it remains unchanged.

For example:

  • hello worldellohay orldway
  • Hi, how are you?iHay, owhay reaay ouyay?

inputFormat

The input consists of a single line containing a sentence. The sentence may include multiple spaces, letters, and punctuation marks.

outputFormat

Output the transformed sentence in Pig Latin, preserving the original punctuation and spacing.

## sample
hello world
ellohay orldway