Created
February 8, 2022 20:05
-
-
Save voglster/818c6c8a676d05ee336b06418e2de6a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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