dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
86 lines
3.4 KiB
Markdown
86 lines
3.4 KiB
Markdown
---
|
|
id: 697a49e9860d24853adef67b
|
|
title: "Challenge 190: 2026 Winter Games Day 11: Ice Hockey"
|
|
challengeType: 29
|
|
dashedName: challenge-190
|
|
---
|
|
|
|
# --description--
|
|
|
|
Given an array of 6 ice hockey teams and their records after the round robin games, determine the match-ups for the semi-final round.
|
|
|
|
- Each array item will have a team and their record in the format `"TEAM: W-OTW-OTL-L"`. Where:
|
|
- `"W"` is the number of wins in regulation, worth 3 points each
|
|
- `"OTW"` is the number of overtime wins, worth 2 points each
|
|
- `"OTL"` is the number of overtime losses, worth 1 point each
|
|
- `"L"` is the number of losses, worth 0 points each
|
|
|
|
For example, `"FIN: 2-2-1-0"` would have 11 points after adding up their record.
|
|
|
|
Find the total number of points for each team and return `"The semi-final games will be (1st) vs (4th) and (2nd) vs (3rd)."`. For example, `"The semi-final games will be FIN vs SWE and CAN vs USA."`
|
|
|
|
# --hints--
|
|
|
|
`get_semifinal_matchups(["CAN: 2-2-0-1", "FIN: 2-2-1-0", "GER: 1-0-1-3", "SUI: 0-1-3-1", "SWE: 1-1-2-1", "USA: 2-1-0-2"])` should return `"The semi-final games will be FIN vs SWE and CAN vs USA."`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(get_semifinal_matchups(["CAN: 2-2-0-1", "FIN: 2-2-1-0", "GER: 1-0-1-3", "SUI: 0-1-3-1", "SWE: 1-1-2-1", "USA: 2-1-0-2"]), "The semi-final games will be FIN vs SWE and CAN vs USA.")`)
|
|
}})
|
|
```
|
|
|
|
`get_semifinal_matchups(["CAN: 2-1-1-1", "CZE: 1-1-1-2", "FIN: 1-2-1-1", "NOR: 0-1-1-3", "SLO: 1-0-1-3", "USA: 5-0-0-0"])` should return `"The semi-final games will be USA vs CZE and CAN vs FIN."`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(get_semifinal_matchups(["CAN: 2-1-1-1", "CZE: 1-1-1-2", "FIN: 1-2-1-1", "NOR: 0-1-1-3", "SLO: 1-0-1-3", "USA: 5-0-0-0"]), "The semi-final games will be USA vs CZE and CAN vs FIN.")`)
|
|
}})
|
|
```
|
|
|
|
`get_semifinal_matchups(["CAN: 3-2-0-0", "CZE: 2-1-2-0", "LAT: 0-0-1-4", "ITA: 1-1-1-2", "DEN: 1-0-0-4", "USA: 3-1-1-0"])` should return `"The semi-final games will be CAN vs ITA and USA vs CZE."`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(get_semifinal_matchups(["CAN: 3-2-0-0", "CZE: 2-1-2-0", "LAT: 0-0-1-4", "ITA: 1-1-1-2", "DEN: 1-0-0-4", "USA: 3-1-1-0"]), "The semi-final games will be CAN vs ITA and USA vs CZE.")`)
|
|
}})
|
|
```
|
|
|
|
`get_semifinal_matchups(["AUT: 2-2-1-0", "DEN: 1-0-0-4", "ITA: 1-1-1-2", "JPN: 3-2-0-0", "KOR: 2-1-2-0", "LAT: 0-0-1-4"])` should return `"The semi-final games will be JPN vs ITA and AUT vs KOR."`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(get_semifinal_matchups(["AUT: 2-2-1-0", "DEN: 1-0-0-4", "ITA: 1-1-1-2", "JPN: 3-2-0-0", "KOR: 2-1-2-0", "LAT: 0-0-1-4"]), "The semi-final games will be JPN vs ITA and AUT vs KOR.")`)
|
|
}})
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```py
|
|
def get_semifinal_matchups(teams):
|
|
|
|
return teams
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```py
|
|
def get_semifinal_matchups(teams):
|
|
team_points = []
|
|
for team_str in teams:
|
|
name, record = team_str.split(": ")
|
|
W, OTW, OTL, L = map(int, record.split("-"))
|
|
points = W * 3 + OTW * 2 + OTL * 1 + L * 0
|
|
team_points.append((name, points))
|
|
|
|
team_points.sort(key=lambda x: x[1], reverse=True)
|
|
first, second, third, fourth = team_points[:4]
|
|
|
|
return f"The semi-final games will be {first[0]} vs {fourth[0]} and {second[0]} vs {third[0]}."
|
|
```
|