Try the single-house case again. What it looks like to me is that you're making small updates to your code, trying to fix particular cases. Instead, take a deep breath, step back, and look at the whole thing.
*What was the problem before?* findSol wasn't always returning something. *How can we be sure it doesn't happen again?* Make sure there isn't a code path that doesn't return something reasonable. *Under what circumstances does your function not return anything?* When it reaches the end of the function body without returning. *How did it get there?* By going all the way through the loop without returning. *Why might it go all the way through the loop without returning?* *Under what circumstances does it return during the loop?* *Is it possible those circumstances are never met?* When you figure out how the circumstances are never met, think: Do I need to make sure that it always returns in the loop? Or can I let it exit the loop and then return a result? Good luck, Bartholomew On Wed, Mar 25, 2020 at 4:44 AM Sourakanti Mandal <sonusant...@gmail.com> wrote: > 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 > 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 > <https://groups.google.com/d/msgid/google-code/1c2af03d-6d37-4478-a8a7-61bc97f47a24%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAHaiWHN0HNHy0o-a0TsCuL7tqJrU%2B1jcYYn5K7iLWcO2T28v2w%40mail.gmail.com.