Challenge
PastOne concept, three rungs. Reaching rung 1 is the goal, so climb as far as you can.
Building A New List
loops + making lists
Double everything
Write a function called double_all
Return a new list where every number is twice as big. The old list is not changed, and an empty list gives an empty list.
Examples
| Input | Output |
|---|---|
| [1, 2, 3] | [2, 4, 6] |
| [] | [] |
| [0] | [0] |
| [-2] | [-4] |
There are extra hidden tests, so make it work in general, not just for these.
Keep the positive ones
Write a function called keep_positive
Return a new list holding only the numbers bigger than 0, in the same order. Zero is not positive, so it does not go in.
Examples
| Input | Output |
|---|---|
| [1, -2, 3] | [1, 3] |
| [] | [] |
| [-1] | [] |
| [0, 2] | [2] |
There are extra hidden tests, so make it work in general, not just for these.
Bigger than the one before
Write a function called bigger_than_before
Return a new list of the numbers that are bigger than the number just in front of them. The very first number is never included, and two equal numbers do not count. So [1, 3, 2, 5] gives [3, 5].
Examples
| Input | Output |
|---|---|
| [1, 3, 2, 5] | [3, 5] |
| [] | [] |
| [5] | [] |
| [3, 3] | [] |
There are extra hidden tests, so make it work in general, not just for these.
Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.