🏆
FIFA World Cup 2026
Week 23
With the 2026 Fifa World Cup starting in just over a week, you have decided to enter a fantasy football league with your friends where you are required to predict the outcome of the matches - there is a prize at stake and rather than simply going with your gut, you decide to simulate the tournament, based on each team's world rankings
You will simulate all matches from the group stages to the final
The competition has a few main stages:
- Group stage: 12 groups of 4 teams - winner and runner up of each group automatically go through to knockout
- The top 8 3rd place teams by points also qualify - if there are more than 8 teams on the same points, then those ties are sorted by goal difference (i.e. if a team has scored 8 goals and conceded 3, their goal difference is 5, but if they have scored 4 and conceded 7, their goal difference is -3), then world ranking. Technically there are also other things like number of yellow/red cards etc before world ranking is used - but we won't include data to simulate that for this challenge
- Knockout stage: from 32 teams, then 16, 8, 4, 2 and finally just 1 winner
Here is a 2D array representing the 12 groups ('A' to 'L') with 4 teams in each - for example, the first group - group A - consists of the teams Mexico, South Africa, Korea Republic and Czechia, then group B etc
Below shows the world rankings of all ranked teams as of June 2nd 2026 - the data is in JSON format (country : world ranking points) and is ordered in descending order of points (i.e. top teams at the beginning)
The game outcomes will be determined based on the following world ranking differences:
- ≥ 500: 3 goal winning margin
- ≥ 250 and < 500: 2 goal winning margin
- ≥ 100 and < 250: 1 goal winning margin
- < 100: draw (in group stages, draws are possible - in the knockout stages, the team with the higher ranking will be assumed to win on penalties)
For example, suppose team A has 1200 world ranking points while team B has 1400 world ranking points, then, according to these rules, team B is predicted to win by 1 goal
If in the knockout stages and the match is determined to be a draw - e.g. between a team of 1500 points vs a team of 1450 points, then the team of 1500 points will be assumed to win on penalties
Next we can see data representing the matches played in the first knockout stages - the round of 32 teams. The numbers/letters represent the position and group of that team - for example, "1E" means the winner of group E, while "2A" means the runner up of group A. A question mark "?" means one of the 8 3rd place teams (how to determine which team that will be is explained below). The data is in pairs - i.e. indexes 0 and 1 play against each other in match 1, indexes 2 and 3 play in match 2, indexes 4 and 5 play in match 3 etc. Suppose Germany won group E, then they would be the "1E" team and playing against "?" - i.e. one of the 3rd place group stage teams
Below is JSON data mapping the 3rd place qualifiers, with the team they will play against - the data is obtained from Wikipedia here. The key represents the 8 teams that qualified - i.e. in the first row, we see the key "EFGHIJKL" - that means that the top 8 3rd place teams were from those 8 groups - i.e. E, F, G, H, I, J, K, and L. The array contains 8 columns, representing who the winners of groups A, B, D, E, G, I, K, L will play against - A is index 0, B is index 1 and so on. For example, looking at the first row, we see the array ["E","J","I","F","H","G","L","K"], that means that the winner of group A will play the 3rd place of group E, the winner of group B will play 3rd place in group J, the winner of group D will play 3rd place in group I etc. If this is confusing, the Wiki link at the beginning of this paragraph shows the full table of possibilities too
In terms of your program output, suppose we instead we simulated a hypothetical identical competition format, but using data for the top clubs in Europe according to UEFA rankings - here are the groups:
...and team rankings of:
Note that since the UEFA point scores are much lower/yet have a greater relative standard deviation, then a team ranking difference of less than 20 points is assumed to be a draw, a difference of 20 <= x < 40 was assumed to be a win by 1 goal, a difference of 40 <= x < 80 was assumed to be a win by 2 goals and anything greater is considered a win by 3 goals
Then the format would be as follows - note what is required:
- Group match outcomes and tables displayed - the table data/order is position, team name, points, goal difference - e.g. Roma were 1st in their group achieving 7 points and having a goal difference of positive 2
- All third-place teams orders and output in same format as the group table and split by those who qualified/were eliminated
- Knockout round headings and simulated games - the numbers like "1.", "2." mean the game number - i.e. game 1 consists of teams at indexes 0 and 1 in the knockout bracket, game 2 consists of teams at indexes 2 and 3 etc
Also note some important features formatting/grammar:
- Correct plurality should be used - i.e. "1 goal" compared with "2 goals"
- The winning team should always be displayed first - i.e. "Y beat X by 2 goals" and NOT "X lost to Y by 2 goals" - this consistent format makes it easier to mark
- The group matches can be output in any order - i.e. imagine teams 1, 2, 3 and 4 in Group A - you could output the game between 1 and 4 first, or the game between 2 and 3, or any other order you please
For your program, you should use the real world cup data provided - the data should be in an identical format to this example above, otherwise the answer won't be marked correct
Hints
Hints will be released at the start of each of the following days - e.g. the start of day 3 is 48 hours after the challenge starts
| Release Day | Hint |
|---|---|
| 2 | You can use the ASCII code of the group name ('A', 'B', 'C' etc) to calculate what index in the group table that group corresponds to |
| 3 | A logical way to loop through the matches would be to simulate team A playing against B, C and D...then simulate team B playing against C and D (since you have already simulated A and B playing against each other), then simulate C playing D - i.e. 6 matches total. This can be done with a nested for loop and thinking carefully about the loop starting index |
| 4 | You should get the world ranking points and determine the result (points and goal difference) accordingly - the team's points/goal difference should be updated with this data. It should then be easy to sort the teams by points once all matches have been played and output the table |
| 5 | All 3rd place teams could then be added to a temporary array and sorted by the criteria - first points, then goal difference and finally world ranking for any ties |
| 6 | You will then want an alphabetically-ordered string of the 8 groups these 3rd place qualifiers came from - that should then allow you to determine the round of 32 knockout match these 3rd place teams will be playing in |
| 7 | You could simulate the knockouts by creating e.g. a new array/tree for each round, but a simpler option would be to simply add the winner from each match to the next available position in the array - for example, in the round of 32, the array indexes 0-31 will be used - the winner of match 1 can be placed in the first array index (0), the winner of match 2 can be placed at index 1, the winner of match 3 at index 2 etc. You will now have these 16 qualifiers in indexes 0-15 of the array and you can do the same process again to get the quarter final knockout array |