Answer the question
In order to leave comments, you need to log in
How to iterate over nth order matrix minors in python?
I solve the problem "to implement the Gauss method". I can not give birth to an algorithm for a function that would take a matrix and the order of a minor as an argument and go through all the minors of the corresponding order.
The problem boils down to a simpler one: there is a set, how to iterate over all combinations of an arbitrary number of elements?
Answer the question
In order to leave comments, you need to log in
The problem boils down to a simpler one: there is a set, how to iterate over all combinations of an arbitrary number of elements?
Kombnatorika is an interesting thing. here are the solutions:
http://ru.stackoverflow.com/questions/154252/All-in...
... how to iterate over all combinations of an arbitrary number of elements?
>>> import itertools
>>> num = '123'
>>> list(itertools.permutations(num))
[('1', '2', '3'), ('1', '3', '2'), ('2', '1', '3'), ('2', '3', '1'), ('3', '1', '2'), ('3', '2', '1')]
>>> letters = ['A', 'B', 'C']
>>> list(itertools.permutations(letters))
[('A', 'B', 'C'), ('A', 'C', 'B'), ('B', 'A', 'C'), ('B', 'C', 'A'), ('C', 'A', 'B'), ('C', 'B', 'A')]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question