Help on mathematics

I need a little tutoring in math.

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.

1 Like

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.

3 Likes

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.

Btw, the etymological roots of the term “algorithm” are in mathematics. So of course (not only in this case) it’s a math problem. :wink:

1 Like

if highest - lowest >2 AND count(shots.team.a) >2
then winner=highest

1 Like
   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.

This is not enough. This formula does not include the possibilty, that the difference of score is 2 (not >2) but the remaining attempts are 1.

Example:
Team A: OXXO
Team B: XXXX
Match is over.
Team A has 1 attempt left, but must equal 2 goals.
So I added this

You are making this needlessly complicated.
All you need is

LeadingTeamScore - BackTeamScore > backTeamAttempts

If this is satisfied, then it is EndOfMatch

If the score is 3-0 and the trailing team has not yet performed its 3rd attempt (so has 3 attempt left), then

3 - 0 > 3 ?
No, so not end of match.

If then then go with the 3rd shoot and miss, the number of remaining attempt is 2:

3 - 0 > 2 ?
Yes, so end of match.

In your example of Team A having scored twice and B 4 times, and the match has to be over:
4 - 2 > 1 ?
Yes, so end of match.

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.

I do not intend to continue this, admittedly dispensable, discussion, but a little hint yet:

grafik

e.g.: How Mathematicians Think: Using Ambiguity, Contradiction, and Paradox.
Princeton University Press 2007, page 4

PS: Of course, a cooking recipe is not an algorithm.

1 Like

This post was flagged by the community and is temporarily hidden.

https://fiftyexamples.readthedocs.io/en/latest/algorithms.html

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 we please stop discussing what an algoritm is.

1 Like

I did not bring up the argument.

There was no argument in my view. Just sharing points of view. But lets focus on the question of the user.

2 Likes

Well, if you check things, my answer was viewed as the solution by the user; that should have taken care of focusing on the question of the user.

Yet it was one of my post, and my post alone, that was hidden by a community flag.

It was the best answer, but remaining attempts isn’t possible due to other circumstances while gameplay.

But your post helped me the most here! Thanks so far.

And big thanks to @Django_s_Android_App

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?