Did the fever go down?
- O(1) · Trivial
- Free
- Python
- JavaScript
- lists
- indexes
- booleans
Problem
You get the three temperatures someone was checked at during the day, in a list and in the order they were taken: morning, afternoon, night. Return true if the fever kept going down reading after reading, that is, if each temperature is lower than the one before it. With [102, 101, 100.5] you return true.
Staying the same does not count as going down: with [100, 100, 99] you return false, even though the last one is the lowest of the three. Three temperatures always arrive and they can have decimals.
Examples
Down both times
[102, 101, 100.5] → true
Up in the afternoon
[101, 102, 100] → false
Down by a hair
[104, 103.9, 103.8] → true
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def went_down(temps):
passJavaScript
function wentDown(temps) {
}It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.
More O(1) challenges
- Did they pass the class?booleans · conditionals
- Digits the other way rounddigits · operations
- Do the two times overlap?conditionals · booleans · comparisons
- Does it fall in range?conditionals · booleans · comparisons
- Does the photo fit the envelope?lists · conditionals · booleans
- How far apartoperations · comparisons