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

Fix: trailing white space and missing EOL #266

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises/practice/knapsack/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The items are represented by [records](https://lfe.gitbooks.io/reference-guide/content/16.html), defined in `item.lfe`.
Use `item-weight` to get the weight and `item-value` to get the value.
Use `item-weight` to get the weight and `item-value` to get the value.

```
;; Create an item with weight=5, value=50
Expand All @@ -10,4 +10,4 @@ Use `item-weight` to get the weight and `item-value` to get the value.

;; Get the value. Returns 50.
(item-value item)
```
```
20 changes: 10 additions & 10 deletions exercises/practice/knapsack/.meta/example.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
(weight-value (item-weight item))
(value-value (item-value item))
(left-over-capacity (- capacity weight-value)))
(if
(if
(< left-over-capacity 0)
value-without
(let
(let
((value-with
(+
(lists:nth (+ left-over-capacity 1) last-values)
Expand All @@ -22,27 +22,27 @@

(defun next-values
([item last-values -1 acc] acc)
([item last-values capacity acc]
(next-values
item
last-values
(- capacity 1)
([item last-values capacity acc]
(next-values
item
last-values
(- capacity 1)
(cons (find-max item last-values capacity) acc))))

(defun do-maximum-values
(['() last-values capacity] (lists:last last-values))
([(cons item remaining) last-values capacity]
(do-maximum-values
remaining
remaining
(next-values item last-values capacity '())
capacity)))

(defun maximum-value
(('() _capacity) 0)
((items capacity)
(do-maximum-values
(do-maximum-values
items
(lists:duplicate
(lists:duplicate
(+ capacity 1)
0)
capacity)))
2 changes: 1 addition & 1 deletion exercises/practice/knapsack/include/item.lfe
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; This include file defines the item record used in the exercise.
; There shouldn't be any need to modify this file.

(defrecord item weight value)
(defrecord item weight value)
1 change: 0 additions & 1 deletion exercises/practice/knapsack/test/knapsack-tests.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@
(make-item weight 118 value 229)
(make-item weight 120 value 240))
750)))