mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 14:12:27 +01:00
BUGFIX: Properly deep copy array data for coding contracts (#1064)
This commit is contained in:
parent
5277db2c65
commit
011d5e8fd6
@ -67,17 +67,8 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
|
||||
const contract = getCodingContract(ctx, hostname, filename);
|
||||
const data = contract.getData();
|
||||
if (Array.isArray(data)) {
|
||||
// For two dimensional arrays, we have to copy the internal arrays using
|
||||
// slice() as well. As of right now, no contract has arrays that have
|
||||
// more than two dimensions
|
||||
const copy = data.slice();
|
||||
for (let i = 0; i < copy.length; ++i) {
|
||||
if (data[i].constructor === Array) {
|
||||
copy[i] = data[i].slice();
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
// For multi-dimensional arrays, we have to copy the internal arrays as well
|
||||
return JSON.parse(JSON.stringify(data));
|
||||
} else return data;
|
||||
},
|
||||
getDescription: (ctx) => (_filename, _hostname?) => {
|
||||
|
@ -1198,9 +1198,9 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
||||
`"1+01" is not a valid expression`,
|
||||
"Examples:\n\n",
|
||||
`Input: digits = "123", target = 6\n`,
|
||||
`Output: [1+2+3, 1*2*3]\n\n`,
|
||||
`Output: ["1+2+3", "1*2*3"]\n\n`,
|
||||
`Input: digits = "105", target = 5\n`,
|
||||
`Output: [1*0+5, 10-5]`,
|
||||
`Output: ["1*0+5", "10-5"]`,
|
||||
].join(" ");
|
||||
},
|
||||
difficulty: 10,
|
||||
|
Loading…
Reference in New Issue
Block a user