TSOC '16 Contest 1 #2 - Johnny and Garden

View as PDF

Submit solution

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

Problem type

Jonathan Sinners is a 42 year-old gardener born on the 20th of April. He has a large garden in his backyard, currently making him hundreds of thousands of dollars. Having so much money, Johnny hires a file-saving servant for the new advanced computer he uses to distribute his herbs, fungi and onions. Whenever Johnny saves a computer file, the program detects the file format from the extension if it is included, and otherwise, it prompts it from the user. An extension consists of a string up to 5 letters which, if it appears in the file name, follows the first and only period.

Write a program for Johnny so he won't waste his money on servants for doing such simple tasks and he can save up to eventually expand his gardening empire.

Input Specification

The first line of input is Johnny's file name, which may or may not include an extension and is at maximum 25 characters in length.

There will be a second line of input if and only if the first line of input does not contain an extension, and will consist of the extension, without a period.

The file name may include any special characters (including spaces).

Output Specification

The only line of output (which is case-sensitive) will be of the format "file name" - extension, where file name should be replaced with the file name and extension should be replaced by the lowercase form of the extension.

Sample Input 1


Sample Output 1

"blueberryCheeseSales" - docx

Sample Input 2


Sample Output 2

"mushroom_promo_photo" - jpeg


  • 8
    charliezhao06  commented on Dec. 25, 2019, 5:04 a.m.

    The authors contain one of each rank

  • 3
    darkvaytor  commented on Nov. 13, 2016, 5:38 a.m. edited

    "Jonathan Sinners" LOL. He's a gardener and he has servants hmm.. did I watch this before?