This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from string import ascii_letters | |
| from math import log | |
| from math import ceil | |
| def product(alphabet, up_to, repeat=1): | |
| ''' (list of strs, int, int) -> (list of strs) | |
| Return the bounded cartesian product of alphabet with (repeat - 1) | |
| other copies of itself, containing at most up_to elements.''' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sort(L): | |
| '''(list) -> list | |
| Returns a sorted version of list L, where every element in L | |
| must have the same number of dimensions.''' | |
| m_len = len(max(L, key=len)) | |
| assert(all([len(x) == m_len for x in L])) #Make sure all elements have same length | |
| return _sort(L, 0, m_len) | |
NewerOlder