Hello,
I'm trying solve the Milkshake problem[0] from Round 1A of the CodeJam, 2008.
I have a list of costumers' preferences and I need to produce a set of batches
of milkshakes, specifying for each batch if I have to order them malted or
unmalted -- to satisfy all the clients.
Moreover, I have to minimize the number of malted batches.
My idea was to build a list of lists, where each list represents the set of
preferences for a costumer.
preferences = [
[(1,1), (2, 0)], ## That is, flavour1 malted, flavour2 unmalted
...
]
Then I sort the entire list of preferences by the length of each set of
preferences, then sorted again for each set of preferences,
putting the unmalted flavours first, then the malted one.
preferences = [
[(1,1)],
[(1,0), (3,0)],
[(5,0), (1,1), (3,1)],
...
]
By satisfying the costumers, starting from the most "choosey", trying their
"unmalted preferences" first, I thought I was supposed to pick (whenever
possible) the batches that satisfied each costumer, keeping the number of
malted batches the lowest possibile.
Why I'm wrong?
The code that I'm using to generate the solution is here[1].
Thank you in advance!
[0], https://code.google.com/codejam/contest/32016/dashboard#s=p1
[1], https://gist.github.com/giuscri/50046796166ef9fcb0ae
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/72288e08-6b39-4a18-ae06-6418edf5ee9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.