exercism / 8th

Exercism exercises in 8th.
https://exercism.org/tracks/8th
MIT License
4 stars 12 forks source link

Add `knapsack` exercise #183

Closed ErikSchierboom closed 5 months ago

ErikSchierboom commented 5 months ago

Another weird one. When I run the test code in a REPL, they're fine:

For example

"example.8th" f:include G:reset  10 [{"weight": 2, "value": 5}, {"weight": 2, "value": 5}, {"weight": 2, "value": 5}, {"weight": 2, "value": 5}, {"weight": 10, "value": 21}] maximum-value .s
 0 n: 000000010c6f4e50 2  21

and

"example.8th" f:include G:reset 10 [{"weight": 2, "value": 20}, {"weight": 2, "value": 20}, {"weight": 2, "value": 20}, {"weight": 2, "value": 20}, {"weight": 10, "value": 50}] maximum-value .s
 0 n: 000000010c6f4a90 3  80

But when I run bin/test-no-docker -r knapsack the tests fail. I see two possible problems:

I'm at a loss how to fix it. Could you please take a look?

glennj commented 5 months ago

I'll try to dig into it this evening.

glennj commented 5 months ago

This might be the same problem with JSON literals that I saw in phone-number: repeating the same sequence produces different results.

$ 8th
8th 24.02 LIN64 Free (98b29c8c/2024-03-11) custid: 44e5dc98

ok> "example.8th" f:include

ok> 10 [{"weight": 5, "value": 10}, {"weight": 4, "value": 40}, {"weight": 6, "value": 30}, {"weight": 4, "value": 50}] maximum-value

ok> .s
 0 n: 00007f4c42b93b30 2  90

ok> drop

ok> 10 [{"weight": 5, "value": 10}, {"weight": 4, "value": 40}, {"weight": 6, "value": 30}, {"weight": 4, "value": 50}] maximum-value

ok> .s
 0 n: 00007f4c42b933e0 2  100
ErikSchierboom commented 5 months ago

Thanks @glennj for your help!

axtens commented 5 months ago

I take all questions like that to the 8th forum. Ron is very helpful