Skip to content

An algorithm for fast 2D pattern-matching with wildcards.

License

Notifications You must be signed in to change notification settings

kaya3/pattern-match-2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pattern-match-2d.js

An algorithm for fast 2D pattern-matching with wildcards, with a demo app inspired by MarkovJunior (by Maxim Gumin).

Demo example

The algorithm uses a DFA to match individual rows of patterns in the rows of the grid, then another DFA to match the whole patterns by recognising vertical sequences of row matches. Scanning a rectangular area of the grid takes O((w + a)(h + b) + m) time where w, h are the width and height of the area, a, b are the maximum width and height of any pattern, and m is the the number of matches which were either made or broken in the scanned area.

About

An algorithm for fast 2D pattern-matching with wildcards.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published