// trees in the first row should not be counted, but we can see that there is no tree on data[0][0] so we skip error checking
returndata.map((row,i)=>row[i*right]==='#');
// if down is 2, filter out uneven rows from data
if(down===2)
returndata
.filter((_,i)=>i%2===0)
.map((row,i)=>row[i*right]==='#');
}
answer1=treeInRow.filter(el=>el).length
treeInRow=data.map((row,i)=>row[i*3]==='#')
// split input and repeat each line 99 times (we're not sure how far the map goes to the right)
data=input.split('\n').map(el=>el.repeat(99))
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.