Retired

World Cup Frenzy (retired)

Description:

I am a huge fan of the FIFA world cup. However, I am currently in the EST timezone which means I miss most of the games because I am at work. I usually keep live track of the scores though. One of my favorite things to do upon seeing the final score is to play out the goal-scoring orders that may have led to that outcome. I tried counting them one time and my brain froze. That's what code is for, amirite?

Task

Given the final score of a football (soccer if that's what rocks your boat) match, provide the count of all the possible orderings of the goals that were scored.

The function you write will take in a string that represents the final game score as an argument. It is expected to always return a number.

Example

Final score: 3-1

Count: 4

Explanation: The possible orderings include:

  1. team A scored 3 goals, then team B scored 1 goal
  2. team A scored 2 goals, then team B get one back, then team A score final goal, crushing their opponents' hopes
  3. team A scored 1 goal, then team B equalized, then team A scored two more goals
  4. team B scored the first goal but team A pulled an upset comeback by scoring three goals

Notes

  1. There will be an unrealistic number of goals being scored, so count efficiently.
  2. We are not accounting for either of the two halves of the game i.e. no need to try and count whether a goal is scored in the first half or the second half. That will probably be for a later kata.
Combinatorics
Permutations

Similar Kata:

More By Author:

Check out these other kata created by induhiu

Stats:

CreatedDec 8, 2022
Warriors Trained11
Total Skips0
Total Code Submissions69
Total Times Completed10
Python Completions10
Total Stars0
% of votes with a positive feedback rating25% of 6
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes4
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • induhiu Avatar
Ad