You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make new directory $PYTHON_TRACK_DIRECTORY/exercises/knapsack
In $PYTHON_TRACK_DIRECTORY, run bin/get-configlet
Add entry for knapsack in $PYTHON_TRACK_DIRECTORY/config.json (use bin/configlet uuid to generate a new UUID for entry)
Run $PYTHON_TRACK_DIRECTORY/bin/configlet generate -p $SPEC_DIRECTORY -O knapsack $PYTHON_TRACK_DIRECTORY to generate the exercise README.md
Implement test suite $PYTHON_TRACK_DIRECTORY/exercises/knapsack/knapsack_test.py (use existing exercise coinschange as an example)
Create a solution stub $PYTHON_TRACK_DIRECTORY/exercises/knapsack/knapsack.py
Implement example solution $PYTHON_TRACK_DIRECTORY/exercises/knapsack/example.py. This solution may be tested using $PYTHON_TRACK_DIRECTORY/test/check-exercises.py knapsack
Hello, in the config.json entry, should a new UUID be generated (if so how?) ? Or is there an existing UUID for all knapsack exercises in all tracks? What should the difficulty be? Thanks
What parameters would you suggest for the stub function? I was thinking it may be the clearest to pass a list of weights and a list of values (albeit it may be arguably more idiomatic to pass a list of tuples).
When I wrote my implementation, I used a list of dictionaries. I tend to favor mappings for various reasons. In addition, they are an allowed json type, so it makes automatic test generation easier.
Also, another note from the bug text, but I don't think coins is an exercise in this track. Perhaps you meant change?
Activity
omer-g commentedon Mar 30, 2019
Hello, I'd be happy to try and work on this.
omer-g commentedon Apr 1, 2019
Hello, in the
config.jsonentry, should a new UUID be generated (if so how?) ? Or is there an existing UUID for all knapsack exercises in all tracks? What should the difficulty be? Thankscmccandless commentedon Apr 1, 2019
The UUID must be unique for each implementation of the exercise (i.e. this track's
knapsackuuidwill not be the same as another track's).To generate this, use
configlet uuidomer-g commentedon Apr 1, 2019
What parameters would you suggest for the stub function? I was thinking it may be the clearest to pass a list of
weightsand a list ofvalues(albeit it may be arguably more idiomatic to pass a list of tuples).cmccandless commentedon Apr 1, 2019
I think a list of tuples would be best; it better represents that the weights and values are tied together.
AnAccountForReportingBugs commentedon Apr 2, 2019
When I wrote my implementation, I used a list of dictionaries. I tend to favor mappings for various reasons. In addition, they are an allowed json type, so it makes automatic test generation easier.
Also, another note from the bug text, but I don't think
coinsis an exercise in this track. Perhaps you meantchange?cmccandless commentedon Apr 2, 2019
As in
{"weight": 2, "value": 3}? That is fine by me.Nested lists are allowed in JSON; they just have to be homogeneous. That said, I think the dict approach is clearer.
Yes, my mistake. I updated the issue description.
knapsack: implement exercise (#1740)