-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcell.py
37 lines (27 loc) · 948 Bytes
/
cell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Cell:
def __init__(self, value: str):
self.__value = value
def __eq__(self, other):
if not isinstance(other, Cell):
return False
return other.__value == self.__value
def __ne__(self, other):
return not self.__eq__(other)
def __str__(self):
return self.__value
def __repr__(self):
return self.__value
def __len__(self):
return len(self.__value)
def __getitem__(self, item):
return self.__value[item]
def fits_on_mask(self, mask: str):
""" Checks a mask with this object. A mask fits on this if .... """
if len(mask) != len(self.__value):
return False
for i, char in enumerate(mask):
if char in ['0', '1'] and char != self.__value[i]:
return False
return True
def count_substring(self, sub_string: str):
return self.__value.count(sub_string)