Tell us what’s happening:
While all other tests pass, test #6 fails with a rounding error that returns 50.35 instead of 50.36. I could only satisfy this test with a fudge…
if round(cost,2) == 50.35 : cost += 0.01
Copilot tells me there is no sane solution to satisfy all tests by producing the expected results.
Your code so far
def get_streaming_bill(cart, subscription):
return cart
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0
Challenge Information:
Daily Coding Challenge - Streaming Cost
https://www.freecodecamp.org/learn/daily-coding-challenge/2026-06-18
GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/daily-coding-challenge/6a15cadf5f240d05a2649556.md
ILM
June 18, 2026, 9:16am
2
there is an issue with the challenge, it has been reported here
opened 08:33AM - 18 Jun 26 UTC
scope: curriculum
status: waiting triage
daily coding challenge
### Describe the Issue
Daily Coding Challenge 312 ("Streaming Cost") has test c… ases whose expected outputs land on a half-cent rounding boundary, so the "correct" answer depends on the rounding method and the order of operations rather than on any well-defined rule. Three of the six tests are affected:
| Test | Inputs | True total | Expected | `Math.round` (round half up) | Sum-then-multiply |
| - | - | - | - | - | - |
| 2 | `[HD rent, HD buy]`, `premium` | 16.98 × 0.75 = **12.735** | `$12.73` | `$12.74` | `$12.73` |
| 4 | `[4K buy, 4K buy]`, `premium` | 39.98 × 0.75 = **29.985** | `$29.98` | `$29.99` | `$29.98` |
| 6 | `[HD rent, 4K rent, HD buy, 4K buy, HD buy]`, `basic` | 55.95 × 0.9 = **50.355** | `$50.36` | `$50.36` | `$50.35` |
Why this happens:
- The description says "rounded to two decimal places", which a learner reasonably implements as round-half-up via `Math.round(price * 100) / 100`. But `16.98 * 0.75` is stored in IEEE-754 as `12.734999999999999432`, so `Math.round(... * 100) / 100` yields `12.74` while the reference solution's `toFixed(2)` (and Python's `f"{:.2f}"`) yields `12.73`. The expected output only matches because the reference solution happens to use `toFixed`, which silently relies on the floating-point representation rather than on a defined rounding rule. The learner's answer is arguably the more mathematically correct one.
- Test 6 is broken even without changing the rounding method: accumulating per item (what the reference solution does) gives `50.355000000000004 → 50.36`, but summing first and then applying the discount, both using `toFixed`/`.2f`, gives `50.355 → 50.35`. Two equally valid implementations of the same approach disagree.
This affects both the JavaScript and the Python versions, which share the same challenge ID and the same expected outputs.
### Affected Page
https://www.freecodecamp.org/learn/daily-coding-challenge/2026-06-18
### Your code
```js
function getStreamingBill(cart, subscription) {
let price = 0;
for (const movies of cart) {
price += (movies["type"] == "buy") ? buy[movies["format"]] : rent[movies["format"]];
}
switch (subscription) {
case "basic":
price = price * 0.9;
break;
case "premium":
price = price * 0.75;
break;
}
return `$${Math.round(price * 100) / 100}`;
}
```
### Expected behavior
The test inputs should be chosen so no total lands on a half-cent boundary (i.e. the third decimal of the discounted total is clearly 0-4 or 6-9), making the expected output independent of the rounding method and the order of operations. The JavaScript and Python versions must be updated in lockstep so they keep the same inputs and expected outputs.
### Screenshots
N/A
### System
- Device: Laptop
- OS: N/A
- Browser: N/A
- Version: N/A
### Additional context
Source files:
- JavaScript: https://github.com/freeCodeCamp/freeCodeCamp/blob/5a0247f95f5cb675a4409f2eb22603e16eaf4401/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6a15cadf5f240d05a2649556.md#L35-L62
- Python: https://github.com/freeCodeCamp/freeCodeCamp/blob/5a0247f95f5cb675a4409f2eb22603e16eaf4401/curriculum/challenges/english/blocks/daily-coding-challenges-python/6a15cadf5f240d05a2649556.md#L38-L80
btw, there is a way, each challenge contains a solution that passes the tests for testing purposes
It works with (acc.toFixed(2) * subscription).toFixed(2)
All tests
Apparantly taking ths sum of the basic costs first and then multiplying with the discount, and taking the sum of each of the basic costs multiplying with the discount (the way the solution applies), produce different results after rounding.
I think there’s an other issue with the challenge, particularly the Python side. In all test cases format and type are used as keys of dictionary, rather than the strings “format” and “type”. While in normal Python environment it’s permissable to use bulit-in functions or methods as keys of dictionary, apparently it’s not in the test environment. Codes calling item[format] or item[type] result in key error and failures in all tests. Even the solution in the challenge page of Github fails all tests, as it uses item[“format”] and item[“type”] and doesn’t match the keys used in the tests.
In the github page the code is incomplete. Check this Daily Coding Challenge - Streaming Cost
ILM
June 18, 2026, 5:21pm
7
thank you, you are right, that has already been reported
opened 06:48AM - 18 Jun 26 UTC
closed 09:12AM - 18 Jun 26 UTC
scope: curriculum
status: PR in works
### Describe the Issue
In the Python Tests section, the input data for all test… s omits the quotes for the keys. This is permissible for JavaScript, but in Python an error occurs when arguments are passed this way. Executing the code with the specified input results in a KeyError.
### Affected Page
https://www.freecodecamp.org/learn/daily-coding-challenge/2026-06-18
### Your code
```
def get_streaming_bill(cart, subscription):
formats = {
"HD": {"rent": 3.99, "buy": 12.99},
"4K": {"rent": 5.99, "buy": 19.99}
}
discounts = {
"none": 0,
"basic": 0.10,
"premium": 0.25
}
total_price = 0
for movie in cart:
discount = discounts[subscription]
format = movie["format"]
type = movie["type"]
total_price += formats[format][type] * (1 - discount)
return f"${total_price:.2f}"
```
### Expected behavior
With correctly submitted data, all tests pass.
### Screenshots
<img width="1920" height="1080" alt="Image" src="https://github.com/user-attachments/assets/322e7d22-5091-4019-aa7e-0e2ec4d87955" />
### System
- Device: Laptop 1920x1080
- OS: Ubuntu 22.04
- Browser: Firefox
- Version: 151.0.4
### Additional context
Correction suggestion:
1. get_streaming_bill([{ "format": "HD", "type": "rent" }], "none") should return "$3.99".
2. get_streaming_bill([{ "format": "HD", "type": "rent" }, { "format": "HD", "type": "buy" }], "premium") should return "$12.73".
3. get_streaming_bill([{ "format": "HD", "type": "rent" }, { "format": "HD", "type": "rent" }, { "format": "HD", "type": "buy" }], "basic") should return "$18.87".
4. get_streaming_bill([{ "format": "4K", "type": "buy" }, { "format": "4K", "type": "buy" }], "premium") should return "$29.98".
5. get_streaming_bill([{ "format": "HD", "type": "rent" }, { "format": "4K", "type": "rent" }, { "format": "HD", "type": "buy" }, { "format": "4K", "type": "buy" }], "none") should return "$42.96".
6. get_streaming_bill([{ "format": "HD", "type": "rent" }, { "format": "4K", "type": "rent" }, { "format": "HD", "type": "buy" }, { "format": "4K", "type": "buy" }, { "format": "HD", "type": "buy" }], "basic") should return "$50.36".