Files
freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-219-skew-cost-coding.md
Oliver Eyton-Williams ee1e8abd87 feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

51 lines
1.1 KiB
Markdown

---
id: 5900f4481000cf542c50ff5a
title: 'Problem 219: Skew-cost coding'
challengeType: 5
forumTopicId: 301861
dashedName: problem-219-skew-cost-coding
---
# --description--
Let A and B be bit strings (sequences of 0's and 1's).
If A is equal to the leftmost length(A) bits of B, then A is said to be a prefix of B.
For example, 00110 is a prefix of 001101001, but not of 00111 or 100110.
A prefix-free code of size n is a collection of n distinct bit strings such that no string is a prefix of any other. For example, this is a prefix-free code of size 6:
0000, 0001, 001, 01, 10, 11
Now suppose that it costs one penny to transmit a '0' bit, but four pence to transmit a '1'. Then the total cost of the prefix-free code shown above is 35 pence, which happens to be the cheapest possible for the skewed pricing scheme in question. In short, we write Cost(6) = 35.
What is Cost(109) ?
# --hints--
`euler219()` should return 64564225042.
```js
assert.strictEqual(euler219(), 64564225042);
```
# --seed--
## --seed-contents--
```js
function euler219() {
return true;
}
euler219();
```
# --solutions--
```js
// solution required
```