2. Partition modulo n Background Refer to the problem "Partition modulo three" for a discussion on partitioning a set into equivalence classes defined on a relation. Challenge Write a function called partition_modulo_n that accepts an integer n and a list of integers t as its arguments, and returns a dictionary that partitions the list. Each possible remainder, from 0 to n - 1, is a key in the dictionary, with its associated value being a list containing elements from the argument list t that leave that remainder. The function must leave the argument list t unmodified, i.e., partition_modulo_n has no side-effects. Note The dictionary must contain a list value for each possible remainder, even if no elements from the argument list t have that remainder, i.e., if no elements have a given remainder then the list value associated with that remainder key will be an empty list. Elements in the dictionary values must appear in the same order as in the argument list t. n may be negative, in which case the remainders are non-positive by convention.
2. Partition modulo n Background Refer to the problem "Partition modulo three" for a discussion on partitioning a set into equivalence classes defined on a relation. Challenge Write a function called partition_modulo_n that accepts an integer n and a list of integers t as its arguments, and returns a dictionary that partitions the list. Each possible remainder, from 0 to n - 1, is a key in the dictionary, with its associated value being a list containing elements from the argument list t that leave that remainder. The function must leave the argument list t unmodified, i.e., partition_modulo_n has no side-effects. Note The dictionary must contain a list value for each possible remainder, even if no elements from the argument list t have that remainder, i.e., if no elements have a given remainder then the list value associated with that remainder key will be an empty list. Elements in the dictionary values must appear in the same order as in the argument list t. n may be negative, in which case the remainders are non-positive by convention.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 2PE
Related questions
Question
Language is python 3
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning