Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -11,27 +11,27 @@
-- {name weight value quantity wt/val }
items = {
{"map", 9, 150, 1},
{"compass", 13, 35, 1},
{"water", 153, 200, 2},
{"sandwich", 50, 60, 2},
{"glucose", 15, 60, 2},
{"tin", 68, 45, 3},
{"banana", 27, 60, 3},
{"apple", 39, 40, 3},
{"cheese", 23, 30, 1},
{"beer", 52, 10, 3},
{"suntan cream", 11, 70, 1},
{"camera", 32, 30, 1},
{"t-shirt", 24, 15, 2},
{"trousers", 48, 10, 2},
{"umbrella", 73, 40, 1},
{"waterproof trousers", 42, 70, 1},
{"waterproof overclothes", 43, 75, 1},
{"note-case", 22, 80, 1},
{"sunglasses", 7, 20, 1},
{"towel", 18, 12, 2},
{"socks", 4, 50, 1},
{"book", 30, 10, 2},
{"compass", 13, 35, 1},
{"water", 153, 200, 2},
{"sandwich", 50, 60, 2},
{"glucose", 15, 60, 2},
{"tin", 68, 45, 3},
{"banana", 27, 60, 3},
{"apple", 39, 40, 3},
{"cheese", 23, 30, 1},
{"beer", 52, 10, 3},
{"suntan cream", 11, 70, 1},
{"camera", 32, 30, 1},
{"t-shirt", 24, 15, 2},
{"trousers", 48, 10, 2},
{"umbrella", 73, 40, 1},
{"waterproof trousers", 42, 70, 1},
{"waterproof overclothes", 43, 75, 1},
{"note-case", 22, 80, 1},
{"sunglasses", 7, 20, 1},
{"towel", 18, 12, 2},
{"socks", 4, 50, 1},
{"book", 30, 10, 2},
}
-- for output
@ -55,7 +55,7 @@ function print_as_sack(its)
local name,wt,val,q = table.unpack(it)
local fmt_table =
string.format(data_fmt, name, wt, val, q)
string.format(data_fmt, name, wt, val, q)
io.write(fmt_table, "\n")
end
io.write(line, "\n")
@ -99,19 +99,19 @@ function add_up (its, max, excl)
local count = 0
local w = 0
for j = 1, q do
local t_wt = wt +this_weight
if t_wt < max then
this_value = this_value + val
this_weight = t_wt
count = count + 1
end
local t_wt = wt +this_weight
if t_wt < max then
this_value = this_value + val
this_weight = t_wt
count = count + 1
end
end
if this_weight >= max then break end
if count > 0 then
_s = {name, count}
table.insert (sack, _s)
_s = {name, count}
table.insert (sack, _s)
end
::continue:: --skip item, continue
@ -120,24 +120,24 @@ function add_up (its, max, excl)
-- go through chosen sack
-- make sack of items
for s = 1,#sack do
local s_item = sack[s]
local s_name,s_count = table.unpack(s_item)
local s_item = sack[s]
local s_name,s_count = table.unpack(s_item)
for j = 1,#its do
local it = its[j]
local iname = it[1]
if iname == s_name then
it[4] = s_count
table.insert(sack_items, it)
end -- if
end -- for j
for j = 1,#its do
local it = its[j]
local iname = it[1]
if iname == s_name then
it[4] = s_count
table.insert(sack_items, it)
end -- if
end -- for j
end -- for sack
-- update best
if this_value > best_value then
best_value = this_value
best_weight = this_weight
best_sack = sack_items
best_value = this_value
best_weight = this_weight
best_sack = sack_items
end
end -- function add_up