Is the big bottle worth it?
- O(1) · Trivial
- Free
- Python
- JavaScript
- operations
- booleans
Problem
The same juice comes in two bottles. Take the price and the liters of the small one (ps, ls) and the price and the liters of the big one (pb, lb). The big one almost always costs more in total, so that on its own says nothing: return true only if a liter comes out cheaper in the big bottle. If a liter costs the same in both, return false.
Examples
18, 1, 30, 2 → true
12, 1, 50, 3 → false
Half a liter
25, 1.5, 30, 2 → true
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def worth_it(ps, ls, pb, lb):
passJavaScript
function worthIt(ps, ls, pb, lb) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.