I find it interesting how implementing a simple algorithm can teach you so many new things.
I was recently implementing the fractional knapsack problem
The interesting was – during implementation I got to learn some interesting things about Python.
- sorted
- items, iteritems
- itemgetter
- https://stackoverflow.com/questions/15371691/how-to-sort-a-dictionary-by-value-desc-then-by-key-asc
- cool trick to sort by combination of ascending and descending
- https://stackoverflow.com/questions/15371691/how-to-sort-a-dictionary-by-value-desc-then-by-key-asc
- sys.stdin
- EOF literal for Windows is Control+Z (not Control+D)
Code: