I want to create a constant variable whose structure looking like this:
const example_order_3_lines = [
{
order_id: 111_222_333,
line_items:[
{
title: 'cookie',
quantity: 5,
space: 0.5,
},
{
title: 'md meal',
quantity: 3,
space: 2.0,
},
{
title: 'lg meal',
quantity: 4,
space: 3.0,
},
{
title: 'soup',
quantity: 2,
space: 2.5,
},
{
title: 'apple pie',
quantity: 3,
space: 1,
}
],
},
];
but when I run that cell I got this error:
File "<ipython-input-60-44a3630eacc1>", line 1
const example_order_3_lines = [
^
SyntaxError: invalid syntax
when i remove const from the variable it give this error:
NameError Traceback (most recent call last)
<ipython-input-64-a12c8a34587f> in <module>
1 example_order_3_lines = [
2 {
----> 3 order_id: 111_222_333,
4 line_items:[
5 {
NameError: name 'order_id' is not defined
Can someone help me what is wrong in this.
There is my main function:
function __main__() {
const BAG_SIZE = 4;
const results = solve(example_order_3_lines, BAG_SIZE);
console.log('results: ', results[0].bags.length, JSON.stringify(results[0].bags, null, 2));
}
__main__();
The main task is that I want to create a function 'solve' where it use 'quantity' and 'space' to find minimum bags require for packing. I want to use knapsack method for this.