We have three more list-manipulation exercises today, for those students midway through their beginning programming course who need practice with linked lists:
- Define a function that takes two lists, the second of which is a list of non-negative integers the same length as the first list, and returns a list of elements from the first list, in reverse order, each repeated a number of times as specified by the corresponding element of the second list.
- Rearrange the integers in a list so that all the odd numbers appear before all the even numbers, with both odd and even numbers in the same relative order in the output as they were in the input.
- Write a function that returns the nth item from the end of a list.
Ver la entrada original 421 palabras más