Hacker News new | past | comments | ask | show | jobs | submit login

   grid.slice(x,x+3)
Turns the 10x10 array into a 3x10 discarding the rows before and after the target rows.

If the second value in slice is larger than the length it slices to the end. It could be a 2x10 or 1x10 but lets pretend it is 3.

   .map(g=>g.slice(y,y+3))
Does the same with each row making it into a 3x3 (or 2x3 or 1x1 etc)

   .flat()
Turns the 3x3 into a flat array of up to 9 values.

   .includes(num)
tests if the flat sliced array include num.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: