aboutsummaryrefslogtreecommitdiff
path: root/count_total_coloured_cell.py
blob: bcff9a90c44a2456de84ae5523a55bf868f68f67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 2579. Count Total Number of Colored Cells

"""
there exists an infinitely large two-dimensional grid of uncoloured unit
cells. you are given a positive integer 'n', indicating that you must do the
following routine for 'n' minutes: at the first minute, colour any arbitrary
unit cell blue, and every minute thereafter, colour blue every uncoloured
cell that touches a blue cell.
"""


class Solution(object):
    def coloredCells(self, n):
        """
        :type n: int
        :rtype: int
        """
        return 1 + 4 * sum(range(n))


if __name__ == "__main__":
    obj = Solution()
    print(obj.coloredCells(n=1))
    print(obj.coloredCells(n=2))