roriscrave
Advanced OT User
- Joined
- Dec 7, 2011
- Messages
- 1,188
- Solutions
- 34
- Reaction score
- 200
I need to check the minimum amount of wood for cutting.
each trunk is 12 meters long, need to cut (10 pieces of 3.5m + 8 pieces of 4.5m + 15 pieces of 5m)
exemple, if i cut 12m in 4,5 + 4,5 there will be 3m left, which will be "lost", as it cannot be used in any other cut
if i cut 1x 5 + 2x3.5 there will be 0m left, and rest 0m "lost".
what is the minimum amount of trunk I can use?
I need the solution that always finds the least amount of "wood scraps"
each trunk is 12 meters long, need to cut (10 pieces of 3.5m + 8 pieces of 4.5m + 15 pieces of 5m)
exemple, if i cut 12m in 4,5 + 4,5 there will be 3m left, which will be "lost", as it cannot be used in any other cut
if i cut 1x 5 + 2x3.5 there will be 0m left, and rest 0m "lost".
what is the minimum amount of trunk I can use?
I need the solution that always finds the least amount of "wood scraps"
Lua:
local trunk = 12 -- (each wood have 12 meters)
local cuts = {
-- ex: he need to cut 10 pieces, with 3,5meters each cut
[1] = {count = 10, meter_each = 3.5},
-- ex: he need to cut 8 pieces, with 4,5meters each cut
[2] = {count = 8, meter_each = 4.5},
-- ex: he need to cut 15 pieces, with 5meters each cut
[3] = {count = 15, meter_each = 5},
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:sendTextMessage(22, "The minimum for cutting is X woods and Y meters.")
return true
end