Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add knapsack exercise #377

Merged
merged 2 commits into from
May 11, 2024
Merged

Add knapsack exercise #377

merged 2 commits into from
May 11, 2024

Conversation

keiravillekode
Copy link
Contributor

No description provided.

@keiravillekode
Copy link
Contributor Author

Naming and arguments are taken from the Scheme track.

@BNAndras BNAndras added x:module/practice-exercise Work on Practice Exercises x:rep/large Large amount of reputation labels May 10, 2024
config.json Outdated
"uuid": "41029de7-58a6-431b-9f82-6d4603604fb3",
"practices": [],
"prerequisites": [],
"difficulty": 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the difficulty should be bumped. Racket marks this an easy exercise (3), Common Lisp as medium (7) and Scheme as hard (8).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected.


(require 'cl-lib)

(defun knapsack (capacity weights values)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the exercise generator use knapsack for the function name? Looking at problem specifications, It should be maximum-value.

Also, the current argument list clashes with the instructions. The docs indicate the items should be a sequence of items with both weight and value stored together. I'd recommend taking a look at the Common Lisp implementation of this exercise.

I'd prefer the function to also be named maximumValue as indicated in problem-specificatins

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had changed the name and argument list to follow the Scheme track.

Now updated to follow problem specifications / Common Lisp.

@BNAndras BNAndras merged commit 7078902 into exercism:main May 11, 2024
2 checks passed
@keiravillekode keiravillekode deleted the knapsack branch May 13, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:module/practice-exercise Work on Practice Exercises x:rep/large Large amount of reputation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants