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
82 lines
3.9 KiB
Markdown
82 lines
3.9 KiB
Markdown
---
|
|
id: 6a0dcd03ee4e68698080ef69
|
|
title: "Challenge 305: Idea Rankings"
|
|
challengeType: 29
|
|
dashedName: challenge-305
|
|
---
|
|
|
|
# --description--
|
|
|
|
Given a 2D array where each inner array contains (in this order) an idea name, an optimistic estimate, a realistic estimate, and a pessimistic estimate (in days), return an array of the idea names sorted by expected time to completion, shortest first.
|
|
|
|
Calculate the expected time to completion for each idea using the following formula:
|
|
|
|
- `expected = ((optimistic + 4 * realistic + pessimistic) / 6) * length of idea name`
|
|
|
|
# --hints--
|
|
|
|
`analyze_ideas([["Add logging", 2, 5, 15], ["SEO optimization", 4, 8, 20], ["Fix bug", 1, 3, 5]])` should return `["Fix bug", "Add logging", "SEO optimization"]`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(analyze_ideas([["Add logging", 2, 5, 15], ["SEO optimization", 4, 8, 20], ["Fix bug", 1, 3, 5]]), ["Fix bug", "Add logging", "SEO optimization"])`)
|
|
}})
|
|
```
|
|
|
|
`analyze_ideas([["Dark mode", 1, 3, 8], ["Real-time collaboration feature", 6, 12, 20], ["Add tooltip", 1, 2, 4]])` should return `["Add tooltip", "Dark mode", "Real-time collaboration feature"]`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(analyze_ideas([["Dark mode", 1, 3, 8], ["Real-time collaboration feature", 6, 12, 20], ["Add tooltip", 1, 2, 4]]), ["Add tooltip", "Dark mode", "Real-time collaboration feature"])`)
|
|
}})
|
|
```
|
|
|
|
`analyze_ideas([["Update user profile page", 3, 7, 14], ["Add pagination", 2, 5, 10], ["Add tags", 2, 3, 6], ["Fix login bug", 1, 4, 8]])` should return `["Add tags", "Fix login bug", "Add pagination", "Update user profile page"]`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(analyze_ideas([["Update user profile page", 3, 7, 14], ["Add pagination", 2, 5, 10], ["Add tags", 2, 3, 6], ["Fix login bug", 1, 4, 8]]), ["Add tags", "Fix login bug", "Add pagination", "Update user profile page"])`)
|
|
}})
|
|
```
|
|
|
|
`analyze_ideas([["Migrate database", 14, 25, 40], ["Add chat assistant", 8, 15, 24], ["Redesign onboarding flow", 3, 7, 13], ["Add language support", 6, 11, 18]])` should return `["Redesign onboarding flow", "Add language support", "Add chat assistant", "Migrate database"]`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(analyze_ideas([["Migrate database", 14, 25, 40], ["Add chat assistant", 8, 15, 24], ["Redesign onboarding flow", 3, 7, 13], ["Add language support", 6, 11, 18]]), ["Redesign onboarding flow", "Add language support", "Add chat assistant", "Migrate database"])`)
|
|
}})
|
|
```
|
|
|
|
`analyze_ideas([["Add email notifications", 3, 7, 10], ["Migrate deployment flow", 6, 10, 16], ["Add push notifications", 2, 6, 10], ["Optimize continuous integration", 5, 8, 15], ["Analyze user patterns", 5, 10, 18], ["Create onboarding curriculum", 6, 15, 25]])` should return `["Add push notifications", "Add email notifications", "Analyze user patterns", "Migrate deployment flow", "Optimize continuous integration", "Create onboarding curriculum"]`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(analyze_ideas([["Add email notifications", 3, 7, 10], ["Migrate deployment flow", 6, 10, 16], ["Add push notifications", 2, 6, 10], ["Optimize continuous integration", 5, 8, 15], ["Analyze user patterns", 5, 10, 18], ["Create onboarding curriculum", 6, 15, 25]]), ["Add push notifications", "Add email notifications", "Analyze user patterns", "Migrate deployment flow", "Optimize continuous integration", "Create onboarding curriculum"])`)
|
|
}})
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```py
|
|
def analyze_ideas(ideas):
|
|
|
|
return ideas
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```py
|
|
def analyze_ideas(ideas):
|
|
def expected(idea):
|
|
name, optimistic, realistic, pessimistic = idea
|
|
return ((optimistic + 4 * realistic + pessimistic) / 6) * len(name)
|
|
return [idea[0] for idea in sorted(ideas, key=expected)]
|
|
```
|