Skip to main content

Compare differences in list order with minimal insertions/deletions

Project description

HashList

This is a package for a list that can display the minimal differences between instances of this type.

This is best demonstrated with Python's go-to metasyntatic values:

menu = [
    HashList(['egg', 'bacon']),
    HashList(['egg', 'sausage', 'bacon']),
    HashList(['egg', 'spam']),
    HashList(['egg', 'bacon', 'spam']),
    HashList(['egg', 'bacon', 'sausage', 'spam']),
    HashList(['spam', 'bacon', 'sausage', 'spam']),
    HashList(['spam', 'egg', 'spam', 'spam', 'bacon', 'spam']),
    HashList(['spam', 'spam', 'spam', 'egg', 'spam']),
    HashList(['spam', 'spam', 'spam', 'spam', 'spam', 'spam', 'baked beans', 'spam', 'spam', 'spam', 'spam']),
    HashList(['lobster thermidor aux crevettes with a mornay sauce, garnished with truffle pâté and a fried egg on top', 'spam'])
]

# Header
end = ', '
for i in range(len(menu)):
    if i == len(menu) - 1:
        end = ': '
    print('Combo {}'.format(i), end=end)
print("Item")
print("-" * 100)

# Table of indicies
for entry in menu[0].diff(menu[1:]):
    end = ', '
    for i in range(len(entry['matches'])):
        match = entry['matches'][i]
        if i == len(entry['matches']) - 1:
            end = ': '
        print('{!r:>7}'.format(match), end=end)
    print(entry['item'])

Output:

Combo 0, Combo 1, Combo 2, Combo 3, Combo 4, Combo 5, Combo 6, Combo 7, Combo 8, Combo 9: Item
----------------------------------------------------------------------------------------------------
      0,       0,       0,       0,       0,    None,       1,       3,    None,    None: egg
      1,       2,    None,       1,       1,       1,       4,    None,    None,    None: bacon
   None,       1,    None,    None,       2,       2,    None,    None,    None,    None: sausage
   None,    None,       1,       2,       3,       0,       0,       0,       0,       1: spam
   None,    None,    None,    None,    None,       3,       2,       1,       1,    None: spam
   None,    None,    None,    None,    None,    None,       3,       2,       2,    None: spam
   None,    None,    None,    None,    None,    None,       5,       4,       3,    None: spam
   None,    None,    None,    None,    None,    None,    None,    None,       4,    None: spam
   None,    None,    None,    None,    None,    None,    None,    None,       5,    None: spam
   None,    None,    None,    None,    None,    None,    None,    None,       6,    None: baked beans
   None,    None,    None,    None,    None,    None,    None,    None,       7,    None: spam
   None,    None,    None,    None,    None,    None,    None,    None,       8,    None: spam
   None,    None,    None,    None,    None,    None,    None,    None,       9,    None: spam
   None,    None,    None,    None,    None,    None,    None,    None,      10,    None: spam
   None,    None,    None,    None,    None,    None,    None,    None,    None,       0: lobster thermidor aux crevettes with a mornay sauce, garnished with truffle pâté and a fried egg on top

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hashlist-NickNackGus-1.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hashlist_NickNackGus-1.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file hashlist-NickNackGus-1.0.0.tar.gz.

File metadata

  • Download URL: hashlist-NickNackGus-1.0.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.5.2

File hashes

Hashes for hashlist-NickNackGus-1.0.0.tar.gz
Algorithm Hash digest
SHA256 60c465994b49fd14a536c5460f959a154942e43e7f13bc2c2c578ed158847934
MD5 a3ef5cc98dbd95b32aed9e03e1a13754
BLAKE2b-256 fcb790484c79f04b74276817d6db43fa1b6cbb9e14b8c004fc648be32d7f422b

See more details on using hashes here.

File details

Details for the file hashlist_NickNackGus-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hashlist_NickNackGus-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.5.2

File hashes

Hashes for hashlist_NickNackGus-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19dfef579f06e97ea94b88f8cd0ab8872f672b277873ee6fc7b62c288207c034
MD5 63e65a0468295aaa6ac01623ce0e2251
BLAKE2b-256 acfce82421bb3688d32afa78b93a9caef40fcd6808ddd044da2000b4f12c0487

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page