## python – Foo Bar – Power Hungry challenge test case failed on unknown edge cases

You have too much code.

You first filter the zeros:

``````xs = filter(lambda a: a != 0, xs)
``````

Then you filter the positives in one list and the negatives in another:

``````for num in xs:
if num > 0:
positives.append(num)
elif num < 0:
negatives.append(num)
``````

So why bother with the first filtering? Zeros would not enter any of the lists in this loop; they are naturally filtered.

You sort the `negatives` table unnecessarily. You should only do this if it contains an odd number of elements. And you don't need to protect the test if it contains an odd number of elements by checking if it contains elements.

No positive value and 1 negative value seems a strange special case. If you let the code progress beyond this point, the unique odd value would be removed from the negative array, leaving no positive and no negative values, which seems a special case less "special".

Simplified code:

``````def solution(xs):
negatives = (num for num in xs if num < 0)
positives = (num for num in xs if num > 0)

if len(negatives) % 2 != 0:
negatives.sort()
negatives.pop()

if positives or negatives:
product = 1
for x in positives + negatives:
product *= x

return str(product)

return '0'
``````

This should behave the same as your original code (complete without passing some marginal cases), but should be slightly faster.

Do you really need to sort the `negatives` board? It's a $$O (N log N)$$ surgery. You just need to remove the smallest number of magnitudes from the table, and find and remove it can be done in $$O (N)$$ time.

What is the maximum product of a non-empty subset of `(-4)`?

I have read that if there is only one negative number in the array, you should return 0, but I have also read that you must return the negative value .

Seems unreasonable to return zero in this case, since the only non-empty subset is `(-4)`and the maximum product is `-4`.

But what about `(-4, 0)`? Both `0 > -4` and `-4 * 0 > -4`, so the maximum product is no longer `-4`.

Modification of the code left to the student.

## html – I created my first frontend / backend system. It's too hungry for resources. No suggestion?

I start in web development and the typical type of learning by doing. I just finished my first project. It's totally private and just for test / training reasons.

I have a Tomcat server with php7.1 and a MySQL database with sports results. This database is constantly updated by a Java program.

The website that presents the results calls the database with a php script. (About 2 to 3 joins per query and 3 match requests.) This results in about 100 queries per reload.
This php is reloaded every 10 seconds via jQuery to have some sort of live score.
I made a button in each line to display the details of that match.
When you click on it, php sends SQL requests to get an overview of recent team games or rankings.

I have recognized that the use of processor and memory was not very decent in this regard. And the answer takes 1-2 seconds long enough.

Is there another technology? What sites like futbol24.com would use for example?

cordially

## 5th dnd – If a Lizardfolk druid is in wild form and uses his Hungry Jaws trait, does he use the bite damage of the beast or lizard?

Lizards have a characteristic that gives them natural weapons in the form of their jaws. This bite deals 1d6 Str damage.

Jaw Hungry. In combat, you can engage in a vicious frenzy to feed you. As a bonus, you can make a special attack with your bite. If the attack hits its target, it inflicts its normal damage and you gain temporary hit points (minimum of 1) equal to your build modifier, and you can not use that trait until you have done so. have not finished your rest. (VGM 113)

Assuming you become a form of beast capable of biting, the Hungry Jaws trait should be available to you because racial characteristics are transferred when you transform if the new form is capable of doing so.

Under these circumstances, would you use the raccoal bite of the lizard, or the bite attack belonging to the new form?

## I develop a food applcation for hungry and needy people, thank you for suggesting me the name of the application

Please, suggest me names that show that the app is for hungry people

## How come my Pitbull pretends to love me knowing that he would eat me when he was hungry and that the food was not found?

Oh you! You love your dog and your dog loves you in return.

You might want to read Harlon Ellison "a boy and his dog".

Even after the crisis, your bull will be with you and you will have no worries.

It'll be fun to lose everything. Nothing will survive – except you and your dog!

.

## dnd 5th – How to manage a PC that is hungry for loot?

As others have suggested, this might not be really a problem. Others have mentioned the extra time and the spotlight that this player is flying. My initial concerns were about 1) if this PC does these actions in combat then it does not pull its weight helping in combat and 2) the realism of carrying 10 tons of material.

For 1Some people consider weight restrictions as a minor problem that they might be willing to give up. I've seen games where they do not care, they're looting everything, and computers currently carry 15 swords, 10 daggers, 20 javelins and 5 bows. When they return to town, they can say, "I will keep 3 swords and a bow in my personal chest, I will keep 2 swords, 3 daggers, all the bleachers and a bow, and I will sell the rest." And it's ok for some games.

If the problem of weight is not to be neglected in this game, then instead of saying "If you continue like this, I will apply weight restrictions," say "I understand that we all want to keep everything, but I do not do not really do it. feel like you are applying weight restrictions and keeping track of all weights, so be sure to at least stay reasonable. "And if that player pushes too far after that, you can just say arbitrarily at some point (without really keeping track of weight, but just because it's outdated)" When you pick up that sword, you realize the weight of all yours is a bit too much. All this weight unbalances you. If you do not do something, you will move at a reduced speed and you may notice dexterity problems. "

For 2: Why is it acceptable that this player does not help the fight, especially as a melee combat class? Are battles too easy for this to be of no importance? If this is the case, change the balance of the battles. Is help needed, they barely survive, but does this PC continue to do these things anyway? Then the other PCs (the characters first, not the players) should shout at him. If that does not work, you could have a conversation outside the character between the players under the pretext that this player does not help them in their role.

Player 1: Orcsmash's eyes illuminate at the sight of the bandit leader
bulky wallet, and he tries to tear it off.

other players sigh and make comments

DM: To roll.

Player1: 15

DM: (whatever the result)

Player2: Magicdude is about to burst a vein and he's screaming at Orcsmash,
"Guy! What are you … doing!?! Put your head in this bloody fight!
If I lose a hand because of you, I swear that you will be the next target of
my biggest curse, and that's if I do not eclipse your —
first!!!"

And be sure to let the other player say what is needed, even if it sounds too much to say in a round, as long as the speech is not long, of course. At this point, you can insist, outside of the character, so that the other player plays at least his character in order to help the group at best, and insist that combat flights be avoided when it might put the party in danger. .

If that does not help, they may have to follow through on their threats. And / or, maybe the characters decide to no longer want this barbarian and prefer to replace it with someone who pulls all its weight. If that goes so far, the same player could even play the new PC that replaces the old one, and maybe even be essentially the same character, with just a different name and with the insistence that this "new" "character does not neglect his fighting duties.