You are not logged in. Please login at www.codechef.com to post your questions!

×

# DIVPAIR: Getting python NZEC Error

 0 I am working on the problem "Paying Up". Despite some time spent trying to solve this issue myself I have yet to find the source of this NZEC error. http://www.codechef.com/problems/MARCHA1 Here is the code: It yields the correct answers when I run it. The break statements just make it run a little faster, the code outputs the correct solution without them as well. Hopefully someone will be able to help me out. Thanks in advance! import itertools cases = int(raw_input()) for i in range(cases): found = False inputList = [] notes,request = map(int,raw_input().split()) for j in range(notes): inputList.append(int(raw_input())) for k in range(1,len(inputList)+1): subsets = list(itertools.combinations(inputList,k)) for subset in subsets: sumOfSet = sum(subset) if(sumOfSet == request): found = True break if(found == True): break if(found == False): print "No" else: print "Yes"  asked 07 May '12, 00:20 11●2●2●5 accept rate: 0% 0★admin ♦♦ 19.8k●350●498●541

 1 actually, the itertools module exists, in Python 2.5.4, but not fully featured as it can be nowadays. please check this out ! :) http://docs.python.org/release/2.5.4/lib/itertools-functions.html answered 08 May '12, 00:37 3.4k●2●19●55 accept rate: 20% You are correct. I have adjusted my original post to reflect this. (08 May '12, 02:28) glad to help you. (08 May '12, 02:56)
 0 I was able to figure this out the cause of the error was likely because of the fact that I was trying to make use of the combinations function in the itertools module which didn't exist in python 2.5 (what code chef runs). I was able to get past this by just adjusting my code a little bit and re-submitting in python 3.1.2 This works! http://www.codechef.com/viewsolution/1023655 answered 07 May '12, 22:27 11●2●2●5 accept rate: 0%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "title")
• 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

Question tags:

×558
×528
×434

question asked: 07 May '12, 00:20

question was seen: 2,100 times

last updated: 10 Jul '12, 13:14