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


DIVPAIR: Getting python NZEC Error

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.

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):
    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
        if(found == True):
    if(found == False):
        print "No"
        print "Yes"

asked 07 May '12, 00:20

veknilash's gravatar image

accept rate: 0%

edited 10 Jul '12, 13:14

admin's gravatar image

0★admin ♦♦

actually, the itertools module exists, in Python 2.5.4, but not fully featured as it can be nowadays.

please check this out ! :)


answered 08 May '12, 00:37

cyberax's gravatar image

3★cyberax ♦
accept rate: 20%

You are correct. I have adjusted my original post to reflect this.

(08 May '12, 02:28) veknilash1★

glad to help you.

(08 May '12, 02:56) cyberax ♦3★

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!


answered 07 May '12, 22:27

veknilash's gravatar image

accept rate: 0%

edited 08 May '12, 02:26

toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 07 May '12, 00:20

question was seen: 2,100 times

last updated: 10 Jul '12, 13:14