longest-repeating-and-non-overlapping-pattern

2.0.0 • Public • Published

longest-repeating-and-non-overlapping-pattern

Implementation of the algorithm to find the longest repeating and non overlapping pattern.

Install:

npm install -S longest-repeating-and-non-overlapping-pattern

Examples (see more on tests):

  const findLongestRepeatedPattern = require('longest-repeating-and-non-overlapping-pattern');

  findLongestRepeatedPattern('IPPIPPII') === 'IPP'
  findLongestRepeatedPattern('IPPIP') === 'IP'
  findLongestRepeatedPattern('IPPIPPIP') === 'IPP'

  findLongestRepeatedPattern('PPPPP') === 'PP'

  findLongestRepeatedPattern(['I', 'P', 'P', 'I', 'P', 'P', 'I', 'I']) === ['I', 'P', 'P'])
  findLongestRepeatedPattern(['I', 'P', 'P', 'I', 'P']) === ['I', 'P'])
  findLongestRepeatedPattern(['I', 'P', 'P', 'I', 'P', 'P', 'I', 'P']) === ['I', 'P', 'P'])

Suggestions to improvement:

  • add custom comparator function as a second argument and be able to process the array of objects

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    2
  • 1.0.4
    0

Package Sidebar

Install

npm i longest-repeating-and-non-overlapping-pattern

Weekly Downloads

2

Version

2.0.0

License

MIT

Last publish

Collaborators

  • eduardbcom