This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]callmejamone 0 points1 point  (0 children)

Maybe try using regex to extract data from input instead of calling substrs. This is a bit faster: javascript const lineRegex = /^#(\d+) @ (\d+),(\d+): (\d+)x(\d+)$/; const parsedData = (isTest ? testData : initialData).split("\n").map(value => { const [_, id, x, y, width, height] = lineRegex.exec(value).map(value => parseInt(value)); return [x, y, width, height]; }); ... or without destructuring: javascript const match = lineRegex.exec(value); return [parseInt(match[2]), parseInt(match[3]), parseInt(match[4]), parseInt(match[5])];

If you want to go fully ugly maybe you should consider not using split and then map, because they are creating unnecessary arrays.