×

Error During Submission of Life, the Universe, and Everything

 0 I submitted a solution for the problem "Life, the Universe, and Everything", based on the sample input and output. I got a Run time Error (NZEC). I googled the cause of this error and got to know that online platforms expect input delimited by space. So I changed the code and resubmitted and I got "Wrong Answer". I know my both my solutions work but do not know what CodeChef Expects. Please help. Solution 1: (this gave runtime error, input is as per sample input one below the other)  num=[] while 1: n = input() if (n == ""): break n=int(n) num.append(n) for numbers in num: if (numbers == 42): break print(numbers)  Solution 2: (This gave wrong Answer, input is on one line delimited by space)  a=[int(x) for x in input().split()] for numbers in a: if (numbers == 42): break print(numbers)  asked 26 Jul '18, 09:46 1●1●1●1 accept rate: 0%

 0 Hello ma'am, You need to take input assuming that the input will come in the format given in sample input. Here it is 1 integer input in each line as mentioned in the question here: www.codechef.com/TTPUNE/problems/TEST/ Kindly try and modify your program accordingly. answered 26 Jul '18, 12:56 0★pallavi 1●2●3●3 accept rate: 0% The "Solution 1" was accepting input as per sample. But that gave runtime error NZEC hence I modified the code. The issue is that the question does not specify when to stop the input. I assumed a NULL (i.e. ENTER without value) means the input has stopped and the output should start. (27 Jul '18, 10:59) I submitted this solution and CODECHEF accepted it, even though it does not satisfy the input and output requirements.  while(True): x = int(input()) if x == 42: break else : print (x)  (27 Jul '18, 11:21) The problem says that keep accepting input and print it till the user enters 42. The above program is satisfying the given requirements and so it worked. (27 Jul '18, 18:55) pallavi0★ But it does not match sample input and sample output!!! (28 Jul '18, 10:16)
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Tags:

Seen: 1,431 times

Last updated: 28 Jul '18, 10:16