Common Lisp: failed test case off by 5 - banging my ahead against a wall :(

Associate
Joined
18 Apr 2011
Posts
438
Location
UK
Hello,

so I'm trying to solve this problem using CL (not my brightest idea).

Basically, you give it the number of types of block and the dimensions for these blocks. For example: if I give it a block type of 1 with the dimension 10, 20 & 30, the maximum height is 40, as the block can only be used twice.

All my test cases pass (return what is expected) except the final sample case:

5
31 41 59
26 53 58
97 93 23
84 62 64
33 83 27

Instead of returning 342, it instead returns 337 (-5) and I haven't a clue, where in my code this is going wrong. To me it all looks perfectly good, but obviously something is off I'm not seeing.

If anyone could be so kind to peak at my source which is here, and can possibly hint/point me in the right direction, I would greatly appreciate it

I would paste snippets here, but it's awfully long.
 
Last edited:
Associate
Joined
24 Jun 2008
Posts
1,168
Don't know if it will help but I get shapes (first two are the base):
97,93,23
84,64,62
64,62,84
59,41,31
41,31,59
33,27,83

I can't read lisp though :(

Just a point though. I didn't use block 58,53,26 which gives a worse height than 59,41,31 but would be in the same place in the tower.
The difference in height being 5.
 
Last edited:
Back
Top Bottom