Thanks a Lot <3 <3 Actually single House was returning NONE, and also it had some problems with house list like [25,25] with a budget of 50. I fixed them, but still it gets WA..... Ohh..gosh !
def findSol(arr, budget): if len(arr) == 1 and sum(arr) <= budget: return 1 arr.sort() total = 0 count = 0 for i in range(0, len(arr)): total += arr[i] #if the total exactly matches budget and there are no more elements # ex : [25, 25] with budget 50 if total == budget: count += 1 return count elif total < budget: count += 1 else: return count def main(): t = int(input()) output = [] while t > 0: num_and_budget = input().split() num_and_budget = list(map(int, num_and_budget)) budget = num_and_budget[1] items = input().split() items = list(map(int, items)) output.append(findSol(items, budget)) t -= 1 for i in range(len(output)): print("Case #" + str(i+1) + ": " + str(output[i])) main() -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/1c2af03d-6d37-4478-a8a7-61bc97f47a24%40googlegroups.com.