0

BELOW is the code for the problem MAXCOUNT from codechef.com. The code on submission shows NZEC error.
The code takes first input t as no. of test cases, then for each test case takes input n a integer and the next line consists of space separated n integers Basically I need to return the maximum occuring integer and its count as output.

import numpy as np
import sys
t = int(raw_input())
for i in xrange(t):
    n = raw_input()
    n = int(n)
    a = []
    a =  map(int, raw_input().split())
    print a
    count = np.bincount(a)
    print np.argmax(count),np.max(count)
sys.exit(0)

Someone please help me out with this error.

1 Answer 1

1

The answer to your question is the use of the numpy module, which is not part of the standard library used on CodeChef. If you need to check numpy or another module in an online programming judge, a good way is to use a code sample that you know works and then add the import statement to the top before resubmitting.

For CodeChef in particular, try the basic test with the following code, with and without the import statement:

#Test for modules
import numpy

number_in = int(raw_input())
while number_in != 42:
    print number_in
    number_in = int(raw_input())

As a suggestion, the Counter() function from the collections module will work on CodeChef, you may want to try that instead of numpy. I find however that for many of the problems on that site without numpy or using PyPy it can be quite difficult to meet the timing requirements for solutions.

Sign up to request clarification or add additional context in comments.

1 Comment

Welcome. That is a good answer, well framed, grammatical and making good use of a code snippet.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.