Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part IV: Untangling a List (20 points) Write a function untangle ) that takes the following arguments, in this order 1. numbers: a list of
Part IV: Untangling a List (20 points) Write a function untangle ) that takes the following arguments, in this order 1. numbers: a list of integers 2. len.of.sublist: a positive integer that is used to divide the list into several sub-lists; see below for more details. You may assume that the length of numbers is always a divisible by len.of.sublist. The function splits the list of into a list of sub-lists. How this is done is most easily understood by example. Suppose the given list numbers is [ 5, 6, 7, 8, 9, 10] and len-of-sublist is 2This value of len-of-sublist indicates that each sub-list will have two items. Note that numbers contains 6 elements. Therefore, there will be 3 sub-lists because 6/3-2 1The first integer (5) goes into the first sub-list. CSE 101 -Fall 2017 Page 3 2. The second integer (6) goes into the second sub-list. 3. The third integer (7) goes into the third sub-list. 4. The fourth integer (8) goes into the second position of the first sub-list. 5. The fifth integer(9) goes into the second position of the second sub-list. 6. The sixth integer (10) goes into the second position of the third sub-list The returned list of lists will be: [5,81, 16,91, [7,101 Examples: Function Call untangle ([1,2,3,4,5, 6], 2) untangle ([1,4,7,2,5,8,3,6,9], 3)[[1,2,3], [4,5, 6], [7,8,9]] untangle ([1,2,3], 1) Return Value
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started