Timeline for Python itertools.combinations: how to obtain the indices of the combined numbers within the combinations at the same time
Current License: CC BY-SA 4.0
Post Revisions
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 29, 2020 at 17:02 | review | Close votes | |||
| Jan 2, 2021 at 0:06 | |||||
| Dec 29, 2020 at 17:00 | vote | accept | Maf | ||
| Dec 29, 2020 at 16:06 | answer | added | Arnab De | timeline score: 0 | |
| Dec 29, 2020 at 15:47 | comment | added | Maf | Yes. You right. Thanks! | |
| Dec 29, 2020 at 15:41 | vote | accept | Maf | ||
| Dec 29, 2020 at 16:59 | |||||
| Dec 29, 2020 at 15:35 | comment | added | jonrsharpe |
I don't think the output from your second example is correct, if you're taking combinations of the tuples from enumerate that would be the values and their indices, the first item emitted would be ((0, 7), (1, 5)). What you show would be the output from combinations of the indices alone, e.g. from range(len(my_list)).
|
|
| Dec 29, 2020 at 15:31 | comment | added | Maf |
with zip (indexes, pairs) I can get a single list, but I'd like to know if I can have this without having to call itertools.combinations twice
|
|
| Dec 29, 2020 at 15:26 | answer | added | Daniel Hao | timeline score: 1 | |
| Dec 29, 2020 at 15:17 | comment | added | Maf | Thank you. I'm reading to get the solution ASAP. | |
| Dec 29, 2020 at 15:13 | comment | added | jonrsharpe | See docs.python.org/3/library/functions.html#zip | |
| Dec 29, 2020 at 15:12 | comment | added | Maf | Could you please help me how to do that? | |
| Dec 29, 2020 at 15:11 | comment | added | jonrsharpe |
Just zip the two iterators, rather than consuming them into lists.
|
|
| Dec 29, 2020 at 15:09 | history | asked | Maf | CC BY-SA 4.0 |