Feb-05-2021, 05:34 PM
Could you give a more concrete example? You've talked about bools and ints as an idea, but then your list is all ints, so I'm not sure how this ties together.
pairing in a list
|
Feb-05-2021, 05:34 PM
Could you give a more concrete example? You've talked about bools and ints as an idea, but then your list is all ints, so I'm not sure how this ties together.
Of course. This is all about a swiss pairing system in a chess tournament. I have a dictionary that holds these "values". (like this: dict={1:[True,3], 2:[False,3]...} The idea is bool value is for if the player has got a BYE before, and the number is the points earned. I'm going to pair all the players according to this criterion and I also have a list (or a pair value) that holds a unique number (or the opponent's number) to measure if these two have played together. One more important thing is this pairing thing will happen x times more(depending on turns). To point out my issue, I thought about iterating over the players list and looking for an opponent but I really don't know how to pick paired guys out to another list and continue without them, at the same time picking the guys which have the closest points.
quick edit: I already sorted the players according to their groups and also made a dict that has keys = points and by this way, I have point groups. I thought it would be great to group players with the same points but still, I have no clue about matching them.
Have you considered using a module or something that is a little bit more focused on handling data structures? Such as pandas or something similar. I think it would be a lot easier to 'query' on your data based on specific conditions that way.
Ofcourse, it would be possible to write all the logic by yourself. But do you have a proper design to do so? I think you'll soon find out that it is more complex than it seems now. [EDIT] It's also a good idea to share the code you already have.
Feb-05-2021, 07:57 PM
1. How is this different from your other thread? I merge both threads
2. You keep saying - I don't know how. Maybe you need to consult your learning materials or find a tutorial
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Feb-05-2021, 08:03 PM
(Feb-05-2021, 07:57 PM)buran Wrote: 1. How is this different from your other thread? I merge both threads One is about the algorithm of swiss pairing. The second is about pairing values in a list according to their criterion. After request, I gave the example as swiss pairing. If you know good learning materials for my topic, why don't you share. And If I knew, why would I open a thread? Just delete the thread if you like.
Feb-05-2021, 08:08 PM
(Feb-05-2021, 07:52 PM)Jeff900 Wrote: Have you considered using a module or something that is a little bit more focused on handling data structures? Such as pandas or something similar. I think it would be a lot easier to 'query' on your data based on specific conditions that way. Thanks for advice Jeff. I'm just a beginner and trying to use the fundamentals to figure out the solutions for problems like that. As you said, I lost my way between lots of lists and dictionaries ![]()
Feb-05-2021, 08:32 PM
(Feb-05-2021, 08:08 PM)jakemace Wrote:(Feb-05-2021, 07:52 PM)Jeff900 Wrote: Have you considered using a module or something that is a little bit more focused on handling data structures? Such as pandas or something similar. I think it would be a lot easier to 'query' on your data based on specific conditions that way. If you ask me, it is always a good thing to keep close to the fundamentals! It makes you understand how things works much better. And besides, using modules like pandas gives alot of overhead. So using such modules is not necessarily the best idea.
Feb-06-2021, 07:40 AM
I don't think I fully understand what this "list" looks like,
but when it comes to pairing, why don't you try combinations or variations. You can make a list with all possible pairings and go from there. If you import itertools, this is a piece of cake. Paul |
|