How to rearrange array using Python?
Robin Koch
robin.koch at t-online.de
Thu Jul 30 21:18:20 EDT 2015
Am 30.07.2015 um 22:31 schrieb Martin Schöön:
> Scores to the right show how many wishes are fulfilled in each room
Is it possible the is a mistake in the sum column on the third row?
Should the be a 1?
> The goal is to re-shuffle the array to maximize this score.
>
> How do I go about doing that?
Depending on how you store those wishes I'd think you can use
random.shuffle()!?
But do you think simply maximising the score is the optimal solution to
the problem?
That way some kids will get their both wishes fulfilled (s, e and p in
your example), while other kids not even one (r, z, j, v, c, y, g, m, d).
Shouldn't be the goal to maximise the number of kinds which get at least
one wished kid in the same room? (I hesitate writing "friend", since you
maybe wouldn't want to be picked by someone... Friend would be pairs of
kids picking each other. Another thing one might want to takeinto
account. :-))
--
Robin Koch
More information about the Python-list
mailing list