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

Author:
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

1

Sample Output 1

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

Sample Input 2

4

Sample Output 2

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

Comments


  • -1
    Abhishek_gupta01  commented on Sept. 23, 2024, 7:38 p.m. edited
    N = int(input())
    string_sentence = 'A long time ago in a galaxy ' + 'far, ' * (N - 1) + 'far ' + 'away...'
    print(string_sentence)
    

  • -3
    nan4ik4  commented on Sept. 23, 2024, 11:26 a.m. edit 8

    Loving with Russia

    s1 = int(input())             
    s2 = 'A long time ago in a galaxy'             
    s3 = 'away...'                  
    if s1 < 1 or s1 > 5:              
     print('error! enter from 1 to 5')                         
    else:                           
     s1 = (s1 - 1) * ' far,' 
     print(s2,s1,'far',s3)
    

  • -5
    viz0r  commented on Aug. 6, 2024, 2:28 p.m. edit 8

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -1
    seongdong  commented on July 25, 2024, 1:03 p.m. edit 3
    word1 = 'a long time ago in a galaxy '
    words2 = 'far,'
    words3 = ' away...'
    
    N = int(input())
    K = N * (1 <= N <= 5)
    
    if(K == K):
        print(words1, (words2 * K).strip(","), words3)
    

    • -1
      seongdong  commented on July 25, 2024, 1:10 p.m. edit 3

      My test was successful, but the calculation result of this site is 'Failure'.


      • 0
        SuahSwag24  commented on July 26, 2024, 12:43 a.m.

        ur "A" in the sentence is uncapitalized


  • -1
    Capybala  commented on June 21, 2024, 2:53 a.m. edit 2
    N=int(input())
    words="far,"
    for i in range(0,N-3):
        words=words+("far,")
    print('A long time ago in a galaxy far '+words+"far away...")
    

    My code always outputs 3 far values when the N value input is less than 3. Can someone help me see where the problem lies


  • -1
    lizziebee  commented on May 7, 2024, 9:08 p.m. edit 2

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

    • 0
      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.

        ...


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

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

    a=int(input())
    b= int(1)
    a= a-b
    if(a==0):
        print('A long time ago in a galaxy far away')
    
    else:
        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