#Pattern matching in a grid represented with a `std::vector`

9 messages · Page 1 of 1 (latest)

boreal hill
#

I have a pattern of size x*y represented as a vector of size x*y. And a crafting grid of size c*r, also represented using a vector. Now I need to find if the pattern in the crafting grid matches the pattern (Imagine the minecraft crafting table)

Anyone has some good ideas/algorithms on how to match the pattern? For example I can have the pattern of size 1*2:

s
s

And the crafting table of 3x3:

_s_
_s_
___

And Thus the pattern is matching (_ represents air)

last sandBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

uneven birch
#

a simple solution would be to transform the input to deduplicate it and then use a hash map

unkempt horizon
#

Use some kind of hash

loud egret
#

Everything other than the pattern will be empty, right?

#

Then just trim empty edges

boreal hill
#

Oh ok! Thanks for the advice

last sandBOT
#

@boreal hill Has your question been resolved? If so, type !solved :)

boreal hill
#

!solved