(list,current,previous)=>list.map(// current and previous are simply local vars
(depth)=>{
previous=current;
current=depth;
returncurrent>previous;
}
)
.filter(k=>k)//only pick increased depth scans
.length// finally, return the number of increased depth scans
)
**${AOC.timer(scanner,input,1000)}**
slider=list=>list.map((k,i,a)=>k+a[i-1]+a[i-2])
scanner(input.map((k,i,a)=>k+a[i+1]+a[i+2]))
threes=slider(input)
**${AOC.timer(scanner,threes,1000)}**
testThrees=slider(testlist)
scanner(testThrees)===5
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.