Solving FIFA's 2014 Points Allocation Algorithm with Pseudocode

  • Thread starter Travian
  • Start date
  • #1
Travian
64
0

Homework Statement


In 2014 Fifa (the world governing body for international football) would like to revise the way teams are allocated points for the group stage of the World Cup as shown below:

Result Points
Win 3
Draw 1
Lose 0
Win (with penalty shootout) 2
Lose (with penalty shootout) 1

Design an algorithm using pseudocode that analyses the result of a match and awards points to the two teams accordingly.


Homework Equations





The Attempt at a Solution



Algorithm
Code:
Declare firstTeamGoals, secondTeamGoals, firstPen, secondPen as integer
Write “Please enter first team amount of goals”
Get firstTeamGoals ;
Write “Please enter second team amount of goals”
Get secondTeamGoals ;
IF (firstTeamGoals > secondTeamGoals) THEN
     Write “First team receives 3 points and second team receives 0 points”
ELSEIF (firstTeamGoals < secondTeamGoals) THEN
     Write “First team receives 0 points and Second team receives 3 points”
ELSE
IF (firstTeamGoals == secondTeamGoals)
     Write “Please input the number of scored penalties (first team)”
     Get firstPen ; 
     Write “Please input the number of scored penalties (second team)”
     Get secondPen ;
     IF (firstPen > secondPen) THEN
          Display “First team receives 2 points and second team receives 1 point”
     ELSE
          Display “First team receives 1 point and second team receives 2 points”
     ENDIF
ENDIF
ENDIF

I just want someone to confirm is this right. If not - where's the problem. Thank you.
 
Physics news on Phys.org
  • #2
I'm no expert in soccer/futbol, but when you ask for "number of goals" and then ask for "number of penalty points", I don't think that's correct for this problem. It seems like you should ask if the game was won with a tie-breaking shootout first, and if the answer is no, then ask for the final score. I think "penalty kicks" are different from the tie-breaking shootout. Guess I should learn more about soccer :blushing:
 
  • #3
Well the number of goals scored determines the winner. Isnt that right?
 
  • #4
I don't know enough about soccer (as we in the US call it) to know if your algorithm is correct, particularly the part about the penalty shootouts (or even what that means).

Having said that, I don't think your algorithm is correct, since it doesn't seem to take draws into consideration.

I would think the algorithm would need to see if there was a penalty shootout first.

if (penalty shootout is true) then award 2 pts to winner and 1 pt to loser
otherwise if there is a winner, then award 3pts to winner and 0 pts to loser
otherwise award 1 pt to each team
 
  • #5
Correct, but I think that includes the tie-breaking shootout goals. Your code above seems to assume that you will be given a tie score if there was a shootout after the tie. I apologize if I'm not interpreting the question or misunderstanding how soccer is scored.
 
  • #6
Result Points
Win 3
Draw 1
Lose 0
Win (with penalty shootout) 2
Lose (with penalty shootout) 1

This is what the exercise says. You cannot receive 0 points if you loose after penalty shootout.

And yes, i think i missed the part where extra time commences.
 
  • #7
Better information from wikipedia.org:

http://en.wikipedia.org/wiki/Soccer

wikipedia said:
In league competitions, games may end in a draw, but in some knockout competitions if a game is tied at the end of regulation time it may go into extra time, which consists of two further 15-minute periods. If the score is still tied after extra time, some competitions allow the use of penalty shootouts (known officially in the Laws of the Game as "kicks from the penalty mark") to determine which team will progress to the next stage of the tournament. Goals scored during extra time periods count toward the final score of the game, but kicks from the penalty mark are only used to decide the team that progresses to the next part of the tournament (with goals scored in a penalty shootout not making up part of the final score).

So I guess the tie-breaker shootout goals are handled differently.
 

Similar threads

Replies
26
Views
6K
Replies
12
Views
1K
Replies
45
Views
17K
Replies
5
Views
931
Replies
13
Views
4K
Replies
6
Views
3K
Replies
0
Views
3K
Replies
2
Views
8K
Back
Top