about | help | code help+videos | done | prefs |
sameNeighbors
Given a rectangular 2d ArrayList of String, count how many of the values have all neighbors equal to them. Neighbors are all adjacent values (up/down/left/right) If the value is on the edge, out of bounds values do not count against this. (corners have 2 neighbors, sides have 3 neighbors, all others have 4 neighbors) Note: It helps to arrange the 2D arraylists in rows so you can visually see the examples. sameNeighbors([["a", "a", "a"], ["a", "a", "a"], ["a", "a", "a"], ["a", "a", "a"]]) → 12 sameNeighbors([["a", "a", "a"], ["a", "A", "a"], ["a", "a", "a"], ["a", "a", "a"]]) → 7 sameNeighbors([["a", "a", "b"], ["a", "a", "b"], ["a", "a", "b"]]) → 3 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy