#π I have a list of tuples (each tuple contains a nested 3-tuple and an integer) and need to sort it
92 messages Β· Page 1 of 1 (latest)
@calm blade
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
data looks like this but the numbers change through the list ((1, 2, 3), 4)
Not quite sure what you're asking
ill give example
[((0, 1, 2, 3), 5), ((0, 1, 2), 4), ((0, 1, 3), 4), ((0, 2, 3), 4), ((1, 2, 3), 4)]
data can look like that
why does the first tuple have 4 values?
always a 3 or 4 tuple i messed up the title on this
ok
but i want to maximise the amount of numbers used in the 3/4 tuples
each integer can only be used once
I'm not sure what you mean by maximising the amount of numbers used
if i use (0, 1, 2, 3) the numbers 0, 1, 2, 3 cannot be used in the next one
so (0,1,2,3) and (4,5,6) is a possible combination
but (0,1,2,3) and (0, 5, 6) isnt because 0 has already been used
i want to make sure i use as many numbers as possible tho
the list thats given are the valid ones and i need to take tuples from that list
imagine each number is an id
for a student or something
this is a lot more complex than just a simple sort
you basically need to gather how many groups are needed, and how many available IDs there are
it does because that changes how often each ID may be used
each id can only be used once
you have a fixed number of students?
thats what the initial list is
(student, student, student), irrelevant number
i want to minimise the amount of left out students
but 1 student can be in more than 1 group?
no
then I don't understand what this is
in this example the maximum students used is 4
if there was ((4,5,6), irrelevant number) appended to it then it could be 7
but you cant reuse students
Is this for an assignment? Can you share the writeup for it?
sure
In this task you will finally allocate the Zoomerbinis to their study groups!
Write a function alloc_study_groups(zbinis) where the parameter zbinis is a list of Zoomerbinis, each represented as a (type_id, subjects) tuple (this is again of the same form as in the previous two tasks). The function should compute a set of groups of zbinis such that the number of Zoomerbinis without a group is minimised. We call this an optimal grouping.
and then it goes into detail about how it should be sorted in cases but i think i can do that part
heres an example call
[(0, 3, 4, 5), (1, 2, 6)]
i have a way to generate all possible study groups from the first one
a function generates a list of it
but that means you should know ahead of time how many IDs there will be
which is why I don't understand where this came from
[((0, 3, 4, 5), 8), ((0, 3, 4), 7), ((0, 3, 5), 7), ((0, 4, 5), 7), ((3, 4, 5), 7), ((1, 2, 6), 4)]
so for example if you have 20 people, you have to make as many groups of 3/4 as possible?
generated by function
yeah
i mean its limited to 10 for memory reasons
but 10 students need as many to be in a group
so always a 3, 3, 4?
this is what all possible groups for the stuff above
i mean that would be perfect but not every student gets along so the possible groups are given by a seperate function
running that function gives that
and the answer is at the bottom of this
output*
I'd almost just brute force the answer at this point. Shuffle groups until everyone is happy
yeah i might have to
this would be the answer to the most recent python font stuff i just typed
yes, this makes sense since each person only appears once
yeah
but then what is this?
all possible groups
not every student gets along
i have a function that is imported from a hidden library that return all possible groups
ok so a group you create has to be one of those
they are the possible groups
the number after thr group is used later but doesnt really matter for this part
it will always be yes
so why not just use those? Why do you even have to generate anything?
Just pull valid groups from that list
that list changes depending on input
i input 10 students aswell as classes they take
and it outputs the possible groups
it knows what students get along
Alright I'm lost then
that takes this
[(198, ['FoC', 'Logic']), (138, ['Calc 1']), (14, ['Calc 1']), (66, ['FoC', 'Logic']), (10, ['FoC', 'Logic']), (142, ['FoC', 'Logic']), (66, ['Calc 1'])]
and return the list of all possible groups
198 becomes 0, 138 becomes 1 and so on
how would i even go about bruteforcing it
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.