I would like to calculate the following in my app:

It’s about the penalty shootout in football. Two teams compete against each other and have 5 attempts. The teams take turns against each other. If both teams have already shot three times and it is 3: 0, you do not need to continue.

Even if it is 0-2 and Team B shoots another goal, and a few other circumstances that cause both teams do not have to shoot 5 times. For this there would have to be a rule / formula that could replace all if-then eventualities simply and logically.

Unfortunately, I can not think of anything that includes all eventualities well. If it is 5: 5, it goes on. Both teams continue to shoot and if it is not a draw then a team wins.

Unfortunately I’m pretty bad in math. Maybe someone has a hint.

I don’t think there’s a single formula that will do that. You’ll need to check the score after every penalty once both teams have taken three penalties each.

Your problem is not really a math issue, but an algorithm one.

What you need to do is to assume that the team with the lowest score (in your example, that is the one with zero point) will get points in all the remaining attempts, in this case that would be 5 - 3.

So, you need to check

( highest_scored_team ) greater that ( lowest_scored_team + number_or_remaining_attempts )

If this is true, then the highest_scored_team has won and there is no point in trying more shoot. If not, then the lowest_scoring_team still has a chance.

Once you have reached a 5:5 scenario, then the number of remaining attempt is kept at 1.

Thanks very much so far. I will test it and provide the result including blocks here for review. The process and the blocks are now alreadly in my head. This will be great.

To Process "Attempt.TeamA"
set Counter.AttemptsTeamA + 1
IF attempt.success = true
then
set Score.TeamA + 1
IF ScoreTeamA > ScoreTeamB
then
set TeamLeading.score to get.ScoreTeamA
set TeamNotLeading.score to get.ScoreTeamB
set TeamNotLeading.attemps to get attemptsTeamB
else set TeamLeading.score to get.ScoreTeamB
set TeamNotLeading.score to get.ScoreTeamA
set TeamNotLeading.attempts to get attemptsTeamA
IF TeamLeading.score - TeamNotLeading.score > 2 AND TeamNotLeading.attempts > 2
then call.Process "END OF GAME"
else call.Process "AfterAttempt"

of course I have no idea of coding (that’s why I am using Kodular) but I like it. I can’t stop smiling right now, but it is like a monkey after an attempt to recreate a Picasso to get a banana.

Rather than attempt at launching into semantic discussion (“al-jabr” is supposed to mean “reunion of broken parts” in the context of “bone setting”), I would propose that this hinges on what being “bad at math” means for most people.
And what an algorithm means.
Making a cake is an algorithm, it is a ordered sequence of things to do; but very little math is involved, as far as most people would define math.
That is why I pointed at the difference.

These blocks are working properly in every possible situation except a 4:2 with 1 attempt left for back team. I am working on this (should be easy)
I cannot use remaining attempts because the remaining attempts (5) will exceed if draw after 5 attempts. If leading team scores, back team maybe is allowed to make a last attempt.

Can you expand on that?
Are you saying that there are still instances where the existence of a potentially winning outcome for the lagging team is not properly determined?