Skip to content

Instantly share code, notes, and snippets.

@voglster
Created February 8, 2022 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voglster/818c6c8a676d05ee336b06418e2de6a5 to your computer and use it in GitHub Desktop.
Save voglster/818c6c8a676d05ee336b06418e2de6a5 to your computer and use it in GitHub Desktop.
# given an NxN array of colors (rgb) randomly distributed
# write an function that returns the largest area of the same color
# areas are defined as having a common side (no diagonals)
from random import choice
from typing import Tuple
colors = ("r", "g", "b")
def generate_array(size):
ret = []
for _ in range(size):
row = []
for _ in range(size):
row.append(choice(colors))
ret.append(row)
return ret
data = [
["r", "r", "b"],
["r", "r", "b"],
["r", "g", "r"],
]
expected_output = [
(0, 0),
(0, 1),
(0, 2),
(1, 1),
(1, 0),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment