Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For example, you get a 8x8 picture:
000##000
0##0#000
###0####
0#0#####
#0#0#000
#0##0000
0###0000
00#00000


Now you gotta find the "target" which is a 3x3:

0#0
###
0#0


Every-time the target appears you add one to count, in this case count would be 3


Sample input:
000##000
0##0#000
###0####
0#0#####
#0#0#000
#0##0000
0###0000
00#00000
0#0
###
0#0


Sample Output:
3


What I have tried:

I've done the input part, so add on to it or change it if you want:

Python
import sys
import math


m=[]
a=[]

for i in range(8):
    l=sys.stdin.readline()
    m.append(l[:-1])


for i in range(3):
    c=sys.stdin.readline()
    a.append(c[:-1])
Posted
Updated 30-Jul-20 8:03am
v2

You find the target in picture, at {i,j} (with i and j in the [0..5] range) if (and only if)
target[k][l] == picture[i+k][j+l] is True for every k=0,..,2 and l=0,..,2
It is not a difficult algorithm to implement.
 
Share this answer
 
v2
Quote:
I've done the input part, so add on to it or change it if you want:

The input part is common to every assignment, all the interest of every assignment is to make work on the other part, the one you have done nothing.
You express no problem, no question, you show no try beyond the user input.

Steps to a solution:
- Try to solve the problem by hand.
- Think of your solving method in a mechanical way.
- This is basically your algorithm.
- Now have to translate to code and check if program is working.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900