Yesterday I found the following CP task in the internet:
You are provided with a text file (.txt) in which only A's and B's are written.
Read the file and find out how many 3x3 squares of B's were written in the file.
Example txt file:
ABBBAAA
ABBBABA
BBBBBAA
-> in this case there would be one 3x3 square out of B's
I found the task very exciting and therefore started to develop a Python program to solve the task.
Unfortunately my implementation fails because my program splits the text file into a kind of coordinate system and then stores all x and y values of the B's in two different arrays. It is a bit complicated to explain, but my program failed as soon as there were more than the 3 B's of one square in one line. For this reason it would be very useful for the further development of the program to be able to call a method with two parameters, which returns with the help of true/false, if there is a B at the given coordinate.
Perfect Function:
BOnCoordinate[2, 3] # x, y
-> returns True or false
Does anyone have an idea how I could implement it? Unfortunately I have no experience with this and I can't find a useful tutorial on the internet. Many thanks in advance