Skip to main content

Practice ยท 4 of 5

Count the peaks

CHALLENGE
Difficulty: advanced+25 XP

A cell is a **peak** if its value is strictly greater than the **average of its existing neighbors** (the in-bounds 8 neighbors โ€” corners have 3, edges have 5; the cell itself never counts). Count the peaks. Implement process(int[][] g). Example: {{9,1},{1,1}} โ†’ 1.

Back to lesson: Practice: Grid lab: axes, neighborhoods, walls