Johnny and Garden

View as PDF

Submit solution

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Jonathan Sinners is a 42 year-old gardener born on the 20^{th} 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.


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).


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 lower-case 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, 12:04 a.m.

    The authors contain one of each rank

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

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

  • 0
    cyamonide  commented on Jan. 7, 2016, 9:02 p.m. edit 4

    EDIT: it fixed itself :D

    I've tried submitting twice; it's been five minutes and on the view submission page I'm still getting "We are waiting for a suitable judge to process your submission"

    Anybody else with this problem?

    using c++11