Mainly Tech projects on Python and Electronic Design Automation.

Tuesday, December 02, 2008

Knapsack Problem

The Rosetta Code Blog this week mentioned that entries starting with a K were missing so I reviewed my sources and added a knapsack type problem to RC together with the python solution.



It's not the first time that I've remembered that itertools.product can do arbitrary nested for loops. Before, I would have had to employ recursive function calls.



- Paddy.

5 comments:

  1. Any leads on a task starting with Y? :)

    ReplyDelete
  2. The only thing I could think of would be a program to score or play the game Yahtzee, but the game is commercial.

    ReplyDelete
  3. I'll come up with something for Y.

    ReplyDelete
  4. Hi Michael,
    How you doin' on Y ?

    ReplyDelete
  5. Finding a task starting with Y was difficult. I finally came up with Yuletide Holiday at http://www.rosettacode.org/wiki/Yuletide_Holiday

    "
    A company decides that whenever Xmas falls on a Sunday that they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).

    In what years between 2008 and 2121 will the 25th of December be a Sunday?

    Using any standard date handling libraries of your programming language; compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to y2k type problems.
    "

    - Paddy.

    ReplyDelete

Followers

Subscribe Now: google

Add to Google Reader or Homepage

Go deh too!

whos.amung.us

Blog Archive