'Grouping integers in Python
I have been workling on a monte carlo collision method for gases in a latice. For this, I need to group some integers in an array. To be precise, I want to return an array, which groups the index of these integers. Here is what the program should do:
A = [100, 101, 233, 101, 243, 101, 233, 568, 233]
After grouping return:
G = [[0], [1, 3, 5], [2, 6, 8], [4], [7]]
While I have seen many proposals through "for-loops", I would however, like to accelerate this by vectorizing this process. Does anyone know a solution?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
