blocks searcher added

This commit is contained in:
Dmitry Afanasyev 2021-10-12 12:58:37 +03:00
parent 41106f87b3
commit fb741f4685
2 changed files with 14 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.idea .idea
blocks_test.py blocks_test.py
Anna_blocks.py

View File

@ -1,8 +1,9 @@
import copy import copy
from random import randint from random import randint
from typing import Union
LIST_HEIGHT = 8 LIST_HEIGHT = 9
LIST_WIDTH = 7 LIST_WIDTH = 6
# List generator for check # List generator for check
@ -13,8 +14,8 @@ def list_generator() -> None:
print(f'{test_list[row]},') print(f'{test_list[row]},')
print(']') print(']')
# list_generator()
# list_generator()
arr = [ arr = [
# 0 1 2 3 4 5 6 # 0 1 2 3 4 5 6
@ -75,7 +76,7 @@ class BlockSearcher:
self.changer(self.array_copy, element, temp_element) self.changer(self.array_copy, element, temp_element)
# change doubled values # change doubled values
def changer(self, array: list, element: str, insert: str) -> list: def changer(self, array: list, element: Union[str, int], insert: str) -> list:
for row in range(self.height): for row in range(self.height):
for column in range(self.width): for column in range(self.width):
if array[row][column] == element: if array[row][column] == element:
@ -104,10 +105,14 @@ class BlockSearcher:
# print both arrays for debug # print both arrays for debug
def print(self) -> None: def print(self) -> None:
for row in range(self.height): for row in range(self.height):
print(self.array[row], self.array_copy[row]) print(self.array[row], ' <|> ', self.array_copy[row])
bs = BlockSearcher(arr) bs = BlockSearcher(arr)
bs.analyze() bs.analyze()
# bs.print() # use for DEBUG blocks_count = bs.blocks_count()
print(f'Total blocks: {bs.blocks_count()}') print(f'Total blocks: {blocks_count}')
# ------ use for DEBUG -------
bs.changer(bs.array_copy, 0, '00')
bs.print()