{"id":25890487,"url":"https://github.com/wollmers/lcs","last_synced_at":"2025-10-30T10:06:41.055Z","repository":{"id":31430991,"uuid":"34994551","full_name":"wollmers/LCS","owner":"wollmers","description":"Longest Common Subsequence","archived":false,"fork":false,"pushed_at":"2018-07-18T10:05:37.000Z","size":38,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T10:06:13.356Z","etag":null,"topics":["all-lcs","longest-common-subsequences","perl"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wollmers.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-03T17:35:40.000Z","updated_at":"2019-09-01T15:06:44.000Z","dependencies_parsed_at":"2022-09-09T16:23:54.496Z","dependency_job_id":null,"html_url":"https://github.com/wollmers/LCS","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/wollmers/LCS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wollmers%2FLCS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wollmers%2FLCS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wollmers%2FLCS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wollmers%2FLCS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wollmers","download_url":"https://codeload.github.com/wollmers/LCS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wollmers%2FLCS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014668,"owners_count":26085554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["all-lcs","longest-common-subsequences","perl"],"created_at":"2025-03-02T19:20:02.341Z","updated_at":"2025-10-13T10:06:14.084Z","avatar_url":"https://github.com/wollmers.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nLCS - Longest Common Subsequence\n\n\u003cdiv\u003e\n    \u003ca href=\"https://travis-ci.org/wollmers/LCS\"\u003e\u003cimg src=\"https://travis-ci.org/wollmers/LCS.png\" alt=\"LCS\"\u003e\u003c/a\u003e\n    \u003ca href='https://coveralls.io/r/wollmers/LCS?branch=master'\u003e\u003cimg src='https://coveralls.io/repos/wollmers/LCS/badge.png?branch=master' alt='Coverage Status' /\u003e\u003c/a\u003e\n    \u003ca href='http://cpants.cpanauthors.org/dist/LCS'\u003e\u003cimg src='http://cpants.cpanauthors.org/dist/LCS.png' alt='Kwalitee Score' /\u003e\u003c/a\u003e\n    \u003ca href=\"http://badge.fury.io/pl/LCS\"\u003e\u003cimg src=\"https://badge.fury.io/pl/LCS.svg\" alt=\"CPAN version\" height=\"18\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n# SYNOPSIS\n\n    use LCS;\n    my $lcs = LCS-\u003eLCS( [qw(a b)], [qw(a b b)] );\n\n    # $lcs now contains an arrayref of matching positions\n    # same as\n    $lcs = [\n      [ 0, 0 ],\n      [ 1, 2 ]\n    ];\n\n    my $all_lcs = LCS-\u003eallLCS( [qw(a b)], [qw(a b b)] );\n\n    # same as\n    $all_lcs = [\n      [\n        [ 0, 0 ],\n        [ 1, 1 ]\n      ],\n      [\n        [ 0, 0 ],\n        [ 1, 2 ]\n      ]\n    ];\n\n# DESCRIPTION\n\nLCS is an implementation based on the traditional LCS algorithm.\n\nIt contains reference implementations working slow but correct.\n\nAlso some utility methods are added to reformat the result.\n\n## CONSTRUCTOR\n\n- new()\n\n    Creates a new object which maintains internal storage areas\n    for the LCS computation.  Use one of these per concurrent\n    LCS() call.\n\n## METHODS\n\n- LCS(\\\\@a,\\\\@b)\n\n    Finds a Longest Common Subsequence, taking two arrayrefs as method\n    arguments. It returns an array reference of corresponding\n    indices, which are represented by 2-element array refs.\n\n        # position  0 1 2\n        my $a = [qw(a b  )];\n        my $b = [qw(a b b)];\n\n        my $lcs = LCS-\u003eLCS($a,$b);\n\n        # same like\n        $lcs = [\n            [ 0, 0 ],\n            [ 1, 1 ]\n        ];\n\n- LLCS(\\\\@a,\\\\@b)\n\n    Calculates the length of the Longest Common Subsequence.\n\n        my $llcs = LCS-\u003eLLCS( [qw(a b)], [qw(a b b)] );\n        print $llcs,\"\\n\";   # prints 2\n\n        # is the same as\n        $llcs = scalar @{LCS-\u003eLCS( [qw(a b)], [qw(a b b)] )};\n\n- allLCS(\\\\@a,\\\\@b)\n\n    Finds all Longest Common Subsequences. It returns an array reference of all\n    LCS.\n\n        my $all_lcs = LCS-\u003eallLCS( [qw(a b)], [qw(a b b)] );\n\n        # same as\n        $all_lcs = [\n          [\n            [ 0, 0 ],\n            [ 1, 1 ]\n          ],\n          [\n            [ 0, 0 ],\n            [ 1, 2 ]\n          ]\n        ];\n\n    The purpose is mainly for testing LCS algorithms, as they only return one of the optimal\n    solutions. If we want to know, that the result is one of the optimal solutions, we need\n    to test, if the solution is part of all optimal LCS:\n\n        use Test::More;\n        use Test::Deep;\n        use LCS;\n        use LCS::Tiny;\n\n        cmp_deeply(\n          LCS::Tiny-\u003eLCS(\\@a,\\@b),\n          any(@{LCS-\u003eallLCS(\\@a,\\@b)} ),\n          \"Tiny::LCS $a, $b\"\n        );\n\n- lcs2align(\\\\@a,\\\\@b,$LCS)\n\n    Returns the two sequences aligned, missing positions are represented as empty strings.\n\n        use Data::Dumper;\n        use LCS;\n        print Dumper(\n          LCS-\u003elcs2align(\n            [qw(a   b)],\n            [qw(a b b)],\n            LCS-\u003eLCS([qw(a b)],[qw(a b b)])\n          )\n        );\n        # prints\n\n        $VAR1 = [\n                  [\n                    'a',\n                    'a'\n                  ],\n                  [\n                    '',\n                    'b'\n                  ],\n                  [\n                    'b',\n                    'b'\n                  ]\n        ];\n\n- align(\\\\@a,\\\\@b)\n\n    Returns the same as lcs2align() via calling LCS() itself.\n\n- sequences2hunks($a, $b)\n\n    Transforms two array references of scalars to an array of hunks (two element arrays).\n\n- hunks2sequences($hunks)\n\n    Transforms an array of hunks to two arrays of scalars.\n\n        use Data::Dumper;\n        use LCS;\n        print Dumper(\n          LCS-\u003ehunks2sequences(\n            LCS-\u003eLCS([qw(a b)],[qw(a b b)])\n          )\n        );\n        # prints (reformatted)\n        $VAR1 = [ 0, 1 ];\n        $VAR2 = [ 0, 2 ];\n\n- align2strings($hunks, $gap\\_character)\n\n    Returns two strings aligned with gap characters. The default gap character is '\\_'.\n\n        use Data::Dumper;\n        use LCS;\n        print Dumper(\n          LCS-\u003ealign2strings(\n            LCS-\u003elcs2align([qw(a b)],[qw(a b b)],LCS-\u003eLCS([qw(a b)],[qw(a b b)]))\n          )\n        );\n        $VAR1 = 'a_b';\n        $VAR2 = 'abb';\n\n- fill\\_strings($string1, $string2, $fill\\_character)\n\n    Returns both strings filling up the shorter with $fill\\_character to the same length.\n\n    The default $fill\\_character is '\\_'.\n\n- clcs2lcs($compact\\_lcs)\n\n    Convert compact LCS to LCS.\n\n- lcs2clcs($compact\\_lcs)\n\n    Convert LCS to compact LCS.\n\n- max($i, $j)\n\n    Returns the maximum of two numbers.\n\n## EXPORT\n\nNone by design.\n\n# STABILITY\n\nUntil release of version 1.00 the included methods, names of methods and their\ninterfaces are subject to change.\n\nBeginning with version 1.00 the specification will be stable, i.e. not changed between\nmajor versions.\n\n# REFERENCES\n\nRonald I. Greenberg. Fast and Simple Computation of All Longest Common Subsequences,\nhttp://arxiv.org/pdf/cs/0211001.pdf\n\nRobert A. Wagner and Michael J. Fischer. The string-to-string correction problem.\nJournal of the ACM, 21(1):168-173, 1974.\n\n# SOURCE REPOSITORY\n\n[http://github.com/wollmers/LCS](http://github.com/wollmers/LCS)\n\n# AUTHOR\n\nHelmut Wollmersdorfer \u0026lt;helmut.wollmersdorfer@gmail.com\u003e\n\n\u003cdiv\u003e\n    \u003ca href='http://cpants.cpanauthors.org/author/wollmers'\u003e\u003cimg src='http://cpants.cpanauthors.org/author/wollmers.png' alt='Kwalitee Score' /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n# COPYRIGHT\n\nCopyright 2014- Helmut Wollmersdorfer\n\n# LICENSE\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n\n# SEE ALSO\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwollmers%2Flcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwollmers%2Flcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwollmers%2Flcs/lists"}