WC '15 Contest 2 J1 - A New Hope

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
C# 3.0s
Memory limit: 16M
C# 32M

Problem type
Woburn Challenge 2015-16 Round 2 - Junior Division

"It is a period of civil war. Rebel programs, striking from a hidden computer, have won their first victory against the evil System Tests."

You might be aware that the events of the Star Wars saga took place a long time ago, in a galaxy that was rather far away. But just how far away was it? We can try to describe it by repeating the word far a certain number of times in the following sentence format:

A long time ago in a galaxy far, far away...

In the above example, the word far is repeated twice. However, we'd instead like to repeat it exactly N (1 \le N \le 5) times without changing the rest of the sentence at all. There should be a comma right after each occurrence except for the last one.

Given N, can you produce the correct sentence?

Input Specification

The input consists of a single integer N.

Output Specification

Output on a single line the appropriate sentence with far repeated N times. It must match the correct answer exactly!

Sample Input 1


Sample Output 1

A long time ago in a galaxy far away...

Sample Input 2


Sample Output 2

A long time ago in a galaxy far, far, far, far away...


  • 0
    lizziebee  commented on May 7, 2024, 9:08 p.m. edited

    This worked in my testing but isn't working in the judge, can someone help me figure out where I'm going wrong?

    N = int(input())
    print('A long time ago in a galaxy ' + str('far, '*(N-1)) + 'far away')

    • 1
      lizziebee  commented on May 7, 2024, 9:11 p.m.

      Never mind, the issue was that I forgot to add the "..." at the end of the sentence so it was counting it as incorrect.

      • 0
        Viv_CCGS  commented on May 7, 2024, 11:30 p.m.


  • -1
    pavansai  commented on March 22, 2024, 5:44 p.m.

    I dont understand why my code doest work as i am getting expected output can some one help

    b= int(1)
    a= a-b
        print('A long time ago in a galaxy far away')
        print('A long time ago in a galaxy ' +'far,'*a+'far away')

    • 0
      htoshiro  commented on March 24, 2024, 12:28 a.m.

      where are the ending "..." also you dont need the if statement