From 5b306640ff98912d9620fcce0ab992b11c965e87 Mon Sep 17 00:00:00 2001 From: MsDiala Date: Mon, 21 Dec 2020 23:15:26 +0200 Subject: [PATCH 1/3] ff --- poetry.lock | 327 +++++++++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 1 + 2 files changed, 328 insertions(+) create mode 100644 poetry.lock diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..ca1d6fe --- /dev/null +++ b/poetry.lock @@ -0,0 +1,327 @@ +[[package]] +name = "appdirs" +version = "1.4.4" +description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "atomicwrites" +version = "1.4.0" +description = "Atomic file writes." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "attrs" +version = "20.3.0" +description = "Classes Without Boilerplate" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.extras] +dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface", "furo", "sphinx", "pre-commit"] +docs = ["furo", "sphinx", "zope.interface"] +tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"] +tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six"] + +[[package]] +name = "binarytree" +version = "5.1.0" +description = "Python Library for Studying Binary Trees" +category = "main" +optional = false +python-versions = "*" + +[[package]] +name = "black" +version = "19.10b0" +description = "The uncompromising code formatter." +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +appdirs = "*" +attrs = ">=18.1.0" +click = ">=6.5" +pathspec = ">=0.6,<1" +regex = "*" +toml = ">=0.9.4" +typed-ast = ">=1.4.0" + +[package.extras] +d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] + +[[package]] +name = "click" +version = "7.1.2" +description = "Composable command line interface toolkit" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "colorama" +version = "0.4.4" +description = "Cross-platform colored terminal text." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "more-itertools" +version = "8.6.0" +description = "More routines for operating on iterables, beyond itertools" +category = "dev" +optional = false +python-versions = ">=3.5" + +[[package]] +name = "packaging" +version = "20.8" +description = "Core utilities for Python packages" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.dependencies] +pyparsing = ">=2.0.2" + +[[package]] +name = "pathspec" +version = "0.8.1" +description = "Utility library for gitignore style pattern matching of file paths." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "pluggy" +version = "0.13.1" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.extras] +dev = ["pre-commit", "tox"] + +[[package]] +name = "py" +version = "1.10.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "pyparsing" +version = "2.4.7" +description = "Python parsing module" +category = "dev" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "pytest" +version = "5.4.3" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.5" + +[package.dependencies] +atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} +attrs = ">=17.4.0" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +more-itertools = ">=4.0.0" +packaging = "*" +pluggy = ">=0.12,<1.0" +py = ">=1.5.0" +wcwidth = "*" + +[package.extras] +checkqa-mypy = ["mypy (==v0.761)"] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] + +[[package]] +name = "regex" +version = "2020.11.13" +description = "Alternative regular expression module, to replace re." +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" +category = "dev" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "typed-ast" +version = "1.4.1" +description = "a fork of Python 2 and 3 ast modules with type comment support" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "wcwidth" +version = "0.2.5" +description = "Measures the displayed width of unicode strings in a terminal" +category = "dev" +optional = false +python-versions = "*" + +[metadata] +lock-version = "1.1" +python-versions = "^3.8" +content-hash = "2537178073426b12ce677b5516062b1d529794781cf22b6581b101bb8a206c51" + +[metadata.files] +appdirs = [ + {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, + {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, +] +atomicwrites = [ + {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, + {file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"}, +] +attrs = [ + {file = "attrs-20.3.0-py2.py3-none-any.whl", hash = "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6"}, + {file = "attrs-20.3.0.tar.gz", hash = "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700"}, +] +binarytree = [ + {file = "binarytree-5.1.0-py2.py3-none-any.whl", hash = "sha256:9f21efc73c66cdcc88b97b27eb02c3565e46088cf9b0f66089d221a87c8dc557"}, + {file = "binarytree-5.1.0.tar.gz", hash = "sha256:6b8c5f6b298993015a3181f7e6d88e4b0be6632a649cc690a273a653d8dd6b1b"}, +] +black = [ + {file = "black-19.10b0-py36-none-any.whl", hash = "sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b"}, + {file = "black-19.10b0.tar.gz", hash = "sha256:c2edb73a08e9e0e6f65a0e6af18b059b8b1cdd5bef997d7a0b181df93dc81539"}, +] +click = [ + {file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"}, + {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, +] +colorama = [ + {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, + {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, +] +more-itertools = [ + {file = "more-itertools-8.6.0.tar.gz", hash = "sha256:b3a9005928e5bed54076e6e549c792b306fddfe72b2d1d22dd63d42d5d3899cf"}, + {file = "more_itertools-8.6.0-py3-none-any.whl", hash = "sha256:8e1a2a43b2f2727425f2b5839587ae37093f19153dc26c0927d1048ff6557330"}, +] +packaging = [ + {file = "packaging-20.8-py2.py3-none-any.whl", hash = "sha256:24e0da08660a87484d1602c30bb4902d74816b6985b93de36926f5bc95741858"}, + {file = "packaging-20.8.tar.gz", hash = "sha256:78598185a7008a470d64526a8059de9aaa449238f280fc9eb6b13ba6c4109093"}, +] +pathspec = [ + {file = "pathspec-0.8.1-py2.py3-none-any.whl", hash = "sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d"}, + {file = "pathspec-0.8.1.tar.gz", hash = "sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd"}, +] +pluggy = [ + {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, + {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, +] +py = [ + {file = "py-1.10.0-py2.py3-none-any.whl", hash = "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a"}, + {file = "py-1.10.0.tar.gz", hash = "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3"}, +] +pyparsing = [ + {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, + {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, +] +pytest = [ + {file = "pytest-5.4.3-py3-none-any.whl", hash = "sha256:5c0db86b698e8f170ba4582a492248919255fcd4c79b1ee64ace34301fb589a1"}, + {file = "pytest-5.4.3.tar.gz", hash = "sha256:7979331bfcba207414f5e1263b5a0f8f521d0f457318836a7355531ed1a4c7d8"}, +] +regex = [ + {file = "regex-2020.11.13-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:8b882a78c320478b12ff024e81dc7d43c1462aa4a3341c754ee65d857a521f85"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:a63f1a07932c9686d2d416fb295ec2c01ab246e89b4d58e5fa468089cab44b70"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:6e4b08c6f8daca7d8f07c8d24e4331ae7953333dbd09c648ed6ebd24db5a10ee"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:bba349276b126947b014e50ab3316c027cac1495992f10e5682dc677b3dfa0c5"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:56e01daca75eae420bce184edd8bb341c8eebb19dd3bce7266332258f9fb9dd7"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:6a8ce43923c518c24a2579fda49f093f1397dad5d18346211e46f134fc624e31"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2014_i686.whl", hash = "sha256:1ab79fcb02b930de09c76d024d279686ec5d532eb814fd0ed1e0051eb8bd2daa"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:9801c4c1d9ae6a70aeb2128e5b4b68c45d4f0af0d1535500884d644fa9b768c6"}, + {file = "regex-2020.11.13-cp36-cp36m-win32.whl", hash = "sha256:49cae022fa13f09be91b2c880e58e14b6da5d10639ed45ca69b85faf039f7a4e"}, + {file = "regex-2020.11.13-cp36-cp36m-win_amd64.whl", hash = "sha256:749078d1eb89484db5f34b4012092ad14b327944ee7f1c4f74d6279a6e4d1884"}, + {file = "regex-2020.11.13-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b2f4007bff007c96a173e24dcda236e5e83bde4358a557f9ccf5e014439eae4b"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:38c8fd190db64f513fe4e1baa59fed086ae71fa45083b6936b52d34df8f86a88"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5862975b45d451b6db51c2e654990c1820523a5b07100fc6903e9c86575202a0"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:262c6825b309e6485ec2493ffc7e62a13cf13fb2a8b6d212f72bd53ad34118f1"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:bafb01b4688833e099d79e7efd23f99172f501a15c44f21ea2118681473fdba0"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:e32f5f3d1b1c663af7f9c4c1e72e6ffe9a78c03a31e149259f531e0fed826512"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:3bddc701bdd1efa0d5264d2649588cbfda549b2899dc8d50417e47a82e1387ba"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:02951b7dacb123d8ea6da44fe45ddd084aa6777d4b2454fa0da61d569c6fa538"}, + {file = "regex-2020.11.13-cp37-cp37m-win32.whl", hash = "sha256:0d08e71e70c0237883d0bef12cad5145b84c3705e9c6a588b2a9c7080e5af2a4"}, + {file = "regex-2020.11.13-cp37-cp37m-win_amd64.whl", hash = "sha256:1fa7ee9c2a0e30405e21031d07d7ba8617bc590d391adfc2b7f1e8b99f46f444"}, + {file = "regex-2020.11.13-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:baf378ba6151f6e272824b86a774326f692bc2ef4cc5ce8d5bc76e38c813a55f"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e3faaf10a0d1e8e23a9b51d1900b72e1635c2d5b0e1bea1c18022486a8e2e52d"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:2a11a3e90bd9901d70a5b31d7dd85114755a581a5da3fc996abfefa48aee78af"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d1ebb090a426db66dd80df8ca85adc4abfcbad8a7c2e9a5ec7513ede522e0a8f"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:b2b1a5ddae3677d89b686e5c625fc5547c6e492bd755b520de5332773a8af06b"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:2c99e97d388cd0a8d30f7c514d67887d8021541b875baf09791a3baad48bb4f8"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:c084582d4215593f2f1d28b65d2a2f3aceff8342aa85afd7be23a9cad74a0de5"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:a3d748383762e56337c39ab35c6ed4deb88df5326f97a38946ddd19028ecce6b"}, + {file = "regex-2020.11.13-cp38-cp38-win32.whl", hash = "sha256:7913bd25f4ab274ba37bc97ad0e21c31004224ccb02765ad984eef43e04acc6c"}, + {file = "regex-2020.11.13-cp38-cp38-win_amd64.whl", hash = "sha256:6c54ce4b5d61a7129bad5c5dc279e222afd00e721bf92f9ef09e4fae28755683"}, + {file = "regex-2020.11.13-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1862a9d9194fae76a7aaf0150d5f2a8ec1da89e8b55890b1786b8f88a0f619dc"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux1_i686.whl", hash = "sha256:4902e6aa086cbb224241adbc2f06235927d5cdacffb2425c73e6570e8d862364"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:7a25fcbeae08f96a754b45bdc050e1fb94b95cab046bf56b016c25e9ab127b3e"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:d2d8ce12b7c12c87e41123997ebaf1a5767a5be3ec545f64675388970f415e2e"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:f7d29a6fc4760300f86ae329e3b6ca28ea9c20823df123a2ea8693e967b29917"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:717881211f46de3ab130b58ec0908267961fadc06e44f974466d1887f865bd5b"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:3128e30d83f2e70b0bed9b2a34e92707d0877e460b402faca908c6667092ada9"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:8f6a2229e8ad946e36815f2a03386bb8353d4bde368fdf8ca5f0cb97264d3b5c"}, + {file = "regex-2020.11.13-cp39-cp39-win32.whl", hash = "sha256:f8f295db00ef5f8bae530fc39af0b40486ca6068733fb860b42115052206466f"}, + {file = "regex-2020.11.13-cp39-cp39-win_amd64.whl", hash = "sha256:a15f64ae3a027b64496a71ab1f722355e570c3fac5ba2801cafce846bf5af01d"}, + {file = "regex-2020.11.13.tar.gz", hash = "sha256:83d6b356e116ca119db8e7c6fc2983289d87b27b3fac238cfe5dca529d884562"}, +] +toml = [ + {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, + {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, +] +typed-ast = [ + {file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3"}, + {file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb"}, + {file = "typed_ast-1.4.1-cp35-cp35m-win32.whl", hash = "sha256:0c2c07682d61a629b68433afb159376e24e5b2fd4641d35424e462169c0a7919"}, + {file = "typed_ast-1.4.1-cp35-cp35m-win_amd64.whl", hash = "sha256:4083861b0aa07990b619bd7ddc365eb7fa4b817e99cf5f8d9cf21a42780f6e01"}, + {file = "typed_ast-1.4.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75"}, + {file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652"}, + {file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7"}, + {file = "typed_ast-1.4.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:fcf135e17cc74dbfbc05894ebca928ffeb23d9790b3167a674921db19082401f"}, + {file = "typed_ast-1.4.1-cp36-cp36m-win32.whl", hash = "sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1"}, + {file = "typed_ast-1.4.1-cp36-cp36m-win_amd64.whl", hash = "sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa"}, + {file = "typed_ast-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614"}, + {file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41"}, + {file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b"}, + {file = "typed_ast-1.4.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:f208eb7aff048f6bea9586e61af041ddf7f9ade7caed625742af423f6bae3298"}, + {file = "typed_ast-1.4.1-cp37-cp37m-win32.whl", hash = "sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe"}, + {file = "typed_ast-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355"}, + {file = "typed_ast-1.4.1-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6"}, + {file = "typed_ast-1.4.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907"}, + {file = "typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d"}, + {file = "typed_ast-1.4.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:7e4c9d7658aaa1fc80018593abdf8598bf91325af6af5cce4ce7c73bc45ea53d"}, + {file = "typed_ast-1.4.1-cp38-cp38-win32.whl", hash = "sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c"}, + {file = "typed_ast-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4"}, + {file = "typed_ast-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34"}, + {file = "typed_ast-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:92c325624e304ebf0e025d1224b77dd4e6393f18aab8d829b5b7e04afe9b7a2c"}, + {file = "typed_ast-1.4.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:d648b8e3bf2fe648745c8ffcee3db3ff903d0817a01a12dd6a6ea7a8f4889072"}, + {file = "typed_ast-1.4.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:fac11badff8313e23717f3dada86a15389d0708275bddf766cca67a84ead3e91"}, + {file = "typed_ast-1.4.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:0d8110d78a5736e16e26213114a38ca35cb15b6515d535413b090bd50951556d"}, + {file = "typed_ast-1.4.1-cp39-cp39-win32.whl", hash = "sha256:b52ccf7cfe4ce2a1064b18594381bccf4179c2ecf7f513134ec2f993dd4ab395"}, + {file = "typed_ast-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:3742b32cf1c6ef124d57f95be609c473d7ec4c14d0090e5a5e05a15269fb4d0c"}, + {file = "typed_ast-1.4.1.tar.gz", hash = "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b"}, +] +wcwidth = [ + {file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"}, + {file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"}, +] diff --git a/pyproject.toml b/pyproject.toml index 86421c1..651e9a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ authors = ["JB "] [tool.poetry.dependencies] python = "^3.8" +binarytree = "^5.1.0" [tool.poetry.dev-dependencies] pytest = "^5.2" From f950adb1cf15fb2e2ac722df69fc0ace36a2a101 Mon Sep 17 00:00:00 2001 From: MsDiala Date: Mon, 21 Dec 2020 23:17:11 +0200 Subject: [PATCH 2/3] fff --- .../__pycache__/array_search.cpython-38.pyc | Bin 501 -> 501 bytes .../__pycache__/linked_list.cpython-38.pyc | Bin 411 -> 411 bytes .../stacks_and_queues.cpython-38.pyc | Bin 0 -> 3196 bytes ...cks_and_queues.cpython-38-pytest-6.1.2.pyc | Bin 0 -> 7158 bytes .../data_structures/stacks_and_queues/read.md | 17 +++ .../stacks_and_queues/stacks_and_queues.py | 95 +++++++++++++ .../test_stacks_and_queues.py | 99 ++++++++++++++ .../tree/__pycache__/tree.cpython-38.pyc | Bin 0 -> 4190 bytes .../data_structures/tree/resd.md | 76 +++++++++++ .../data_structures/tree/tree.py | 125 ++++++++++++++++++ 10 files changed, 412 insertions(+) create mode 100644 data_structures_and_algorithms/data_structures/stacks_and_queues/__pycache__/stacks_and_queues.cpython-38.pyc create mode 100644 data_structures_and_algorithms/data_structures/stacks_and_queues/__pycache__/test_stacks_and_queues.cpython-38-pytest-6.1.2.pyc create mode 100644 data_structures_and_algorithms/data_structures/stacks_and_queues/read.md create mode 100644 data_structures_and_algorithms/data_structures/stacks_and_queues/stacks_and_queues.py create mode 100644 data_structures_and_algorithms/data_structures/stacks_and_queues/test_stacks_and_queues.py create mode 100644 data_structures_and_algorithms/data_structures/tree/__pycache__/tree.cpython-38.pyc create mode 100644 data_structures_and_algorithms/data_structures/tree/resd.md create mode 100644 data_structures_and_algorithms/data_structures/tree/tree.py diff --git a/data_structures_and_algorithms/challenges/array_reverse/__pycache__/array_search.cpython-38.pyc b/data_structures_and_algorithms/challenges/array_reverse/__pycache__/array_search.cpython-38.pyc index 5d1378ae7138cb99ca926457d1664e5bcf38efba..f7ea3384fa4873d46fc858a250b84ef0e59c68ad 100644 GIT binary patch delta 20 acmey${FRwIl$V!_0SKlYIlqzn6(ayW*9JuZ delta 20 acmey${FRwIl$V!_0SLlo9oxwLiV*-h?gi2S diff --git a/data_structures_and_algorithms/data_structures/linked_list/__pycache__/linked_list.cpython-38.pyc b/data_structures_and_algorithms/data_structures/linked_list/__pycache__/linked_list.cpython-38.pyc index d4bbf7a9f6c6d01de5b799f24975027f48c2d272..32661f29b5182f9ae65c902941b1a06d31dd6c2c 100644 GIT binary patch delta 20 acmbQuJe!$2l$V!_0SHzuzO<2h0wVw~l?5yS delta 20 acmbQuJe!$2l$V!_0SJ!E9^J@2fe`>L0tB}J diff --git a/data_structures_and_algorithms/data_structures/stacks_and_queues/__pycache__/stacks_and_queues.cpython-38.pyc b/data_structures_and_algorithms/data_structures/stacks_and_queues/__pycache__/stacks_and_queues.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6ced29c9ece8eca9b6efea52bf7b0d13e9a0482b GIT binary patch literal 3196 zcmbtW%WfP+6z$i{v?uli1qcWNw6Y-+#Wq4nL_I>560B@{@@=vcG=#%_0yWUT}Tj{0!F(m*~2cpRQ@3CC*k=3r+53^w`8PL9iU} zEcdD`y>5fUvSg&=xNOJqC|8pqzc=If;UpPW7Q>wliLD!~&&6c; z1d}c%gKB~l4b@U1-c7Zk+IY9rC6HvZZ0r%~mmpfO4u@q*NKI~<)vX{-uXf|M5!9rjlNSi2@ z$T(h;q3y_dFOKcv-~^YkRnCdGj4nxk-d<%ZwO@_K#px9cScJCPtG29V60?CtXmkS~ z1#;=keFAg_?#zq58F2z)fiv)x`zg{c_7x5S)NUtA*(lSGqYN|!S_CZ04{HbyPNQ+2 zW<{DEMQK4Z^KS=Zo|6~7Zp8*8u8{JEXYTqHWqBxME*5?P%`zBI?D3m0TjJ_?;1vOF zS5DHn#)35u?_h#}>7KaeY5^9Uxh`~TkG!?35MrTB1+>Yvp;K4+tsuoT& z=@2&VM0-UJNs=DXv+R5_bSoX~kjB(Grf!=OI zkS-fzgYc~2PpE4A%YciQO-veNF-hq~UY9<)DcqvHj^9QE0?@jRICR|UMjeTKycP%s zeZlIRXq+F2q7DKBQ-uSd2h$JbuvYSL4lfa_vFE2?Rr!5+)o-m&NH(&|yv0fwM`zE? zpkRy%U0AJLh@N=oZY~)n>xJeL7hqbOEmoq0uk(viW8Pu)E~_PW3jj?A2Cgn!gkIPT z{je2oNq-;xYY#!Yi(>zeJl^N+b8$RgDUa8d@`wOLa*=_7z&q>fo*)i6Y#39=`HNLERUBo~aRkpiNmBd*#CE+&Y1pOtt-NnBII z5KX@5H z^wle%{PVOF#SEaB?w|o%0Ph3k1DS6WF=-YpSi&>jufg=t=u!R%0#@N5qPdR5ttdUL z@7E}`(Nvq9>baWf;^IOuDYJ7)h(_Alb?jEMb7Byg^_OdU|CdX#X&gDEM=K)H^d2iaj&&1!MruDk75Uq#{UT1Zo sXi@P$Mp+fDPI$$zzXzrYe@Q>-SwU{0du8}}^&feMW96@~v(dTn55aecTmS$7 literal 0 HcmV?d00001 diff --git a/data_structures_and_algorithms/data_structures/stacks_and_queues/__pycache__/test_stacks_and_queues.cpython-38-pytest-6.1.2.pyc b/data_structures_and_algorithms/data_structures/stacks_and_queues/__pycache__/test_stacks_and_queues.cpython-38-pytest-6.1.2.pyc new file mode 100644 index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8xhDyCge)UJ3nL+?6hD;EL$1TFa^ z#4M6I^GQ`eo^us4AMQx2s?2%MQx)9Hs;aKw?x~vEz`dfbsjF)9rD#`G9l&p8#V@}` zHb`%Lxk$XrxpC#F$<64vpOPiSiyZin&?M747pFtk@6Yn#naErd$MzydWyC%s-5h2z zt@D2u(MRjgF6t91Yzsy1ECuyJF>KGRy3opZmaROOinh*MX?}5;VWj`_CBrsm@NqU;p>x_C`9C3;ya%D&SI#TZ zm5ThS@`H2AVSECz=F=^vH*-6Y%Y)c}KzwV$7uqD@0QJ-I!H{ZFOMaX@fS4dl9C)Ti zoPUZ;K}v}ukQHjj0tk;ZJEep8bft$_P2bBAm>b=EG>ALlAbH$mWk}HGZoU>59ZmFetzYoVj)LBPyVt)$07vQ=z!<_InR0)^{396wD?{iUG5RTuVE#X)d zRhj;Ly4ksPmjG#YNGa=EAXr^&>N)A2L%6xFbp=DJHfSmbI32EaP8=jx`5Hb%K@KmH zebnLyuK5CQ-8arLDv(Km{j1O~a@B$4iuo>A9UmWV@#jDRe!*m7PW9*TrJ_nLN*(@<9Kj17u>YkoQK8z4`_ovy|Gq)`=@Ckp*(7Wf3MX*zL&fota zRFNp)mF(ta;dv4$r4OG)i8j`s79@UXea3F(`)9BB0-1Oe5)RE)dOh#uiJi;5NH;HM zj23KPW(>0RRHB;r5Iyl)p5hw=qy+ov8E5>?fMP8d#QI&b1xUE`RTV9yHIIgVMAym?> ze^`7(?;eu)6^TztEWDL_w7mHM;uADpn`zbc=(mAil}GV~Yj_3PS{^X;r;D^@-lP2c Q=P}LYn#V2Fuhnn=7x7DR#{d8T literal 0 HcmV?d00001 diff --git a/data_structures_and_algorithms/data_structures/tree/resd.md b/data_structures_and_algorithms/data_structures/tree/resd.md new file mode 100644 index 0000000..e216d2e --- /dev/null +++ b/data_structures_and_algorithms/data_structures/tree/resd.md @@ -0,0 +1,76 @@ +Tree Traversals (Inorder, Preorder and Postorder) +Unlike linear data structures (Array, Linked List, Queues, Stacks, etc) which have only one logical way to traverse them, trees can be traversed in different ways. Following are the generally used ways for traversing trees. + + + +Depth First Traversals: +(a) Inorder (Left, Root, Right) : 4 2 5 1 3 +(b) Preorder (Root, Left, Right) : 1 2 4 5 3 +(c) Postorder (Left, Right, Root) : 4 5 2 3 1 + +Breadth First or Level Order Traversal : 1 2 3 4 5 +Please see this post for Breadth First Traversal. + +Inorder Traversal : + +Algorithm Inorder(tree) + 1. Traverse the left subtree, i.e., call Inorder(left-subtree) + 2. Visit the root. + 3. Traverse the right subtree, i.e., call Inorder(right-subtree) +Uses of Inorder +In case of binary search trees (BST), Inorder traversal gives nodes in non-decreasing order. To get nodes of BST in non-increasing order, a variation of Inorder traversal where Inorder traversal s reversed can be used. + + +Preorder Traversal : + +Algorithm Preorder(tree) + 1. Visit the root. + 2. Traverse the left subtree, i.e., call Preorder(left-subtree) + 3. Traverse the right subtree, i.e., call Preorder(right-subtree) +Uses of Preorder +Preorder traversal is used to create a copy of the tree. Preorder traversal is also used to get prefix expression on of an expression tree. + +Postorder Traversal : + +Algorithm Postorder(tree) + 1. Traverse the left subtree, i.e., call Postorder(left-subtree) + 2. Traverse the right subtree, i.e., call Postorder(right-subtree) + 3. Visit the root. +Uses of Postorder +Postorder traversal is used to delete the tree. Please see the question for deletion of tree for details. Postorder traversal is also useful to get the postfix expression of an expression tree. + + +Time Complexity: O(n) +Complexity function T(n) — for all problem where tree traversal is involved — can be defined as: + +T(n) = T(k) + T(n – k – 1) + c + +Where k is the number of nodes on one side of root and n-k-1 on the other side. + +Let’s do an analysis of boundary conditions + +Case 1: Skewed tree (One of the subtrees is empty and other subtree is non-empty ) + +k is 0 in this case. +T(n) = T(0) + T(n-1) + c +T(n) = 2T(0) + T(n-2) + 2c +T(n) = 3T(0) + T(n-3) + 3c +T(n) = 4T(0) + T(n-4) + 4c + +………………………………………… +…………………………………………. +T(n) = (n-1)T(0) + T(1) + (n-1)c +T(n) = nT(0) + (n)c + +Value of T(0) will be some constant say d. (traversing a empty tree will take some constants time) + +T(n) = n(c+d) +T(n) = Θ(n) (Theta of n) + +Case 2: Both left and right subtrees have equal number of nodes. + +T(n) = 2T(|_n/2_|) + c + +This recursive function is in the standard form (T(n) = aT(n/b) + (-)(n) ) + +Auxiliary Space : If we don’t consider size of stack for function calls then O(1) otherwise O(n). \ No newline at end of file diff --git a/data_structures_and_algorithms/data_structures/tree/tree.py b/data_structures_and_algorithms/data_structures/tree/tree.py new file mode 100644 index 0000000..47cbe49 --- /dev/null +++ b/data_structures_and_algorithms/data_structures/tree/tree.py @@ -0,0 +1,125 @@ +class Node: + """Node class definition.""" + + def __init__(self, val=None): + """Create an instance of Node object.""" + self.val = val + self.children = [] + self._next = next + + def __repr__(self): + """Node class representation.""" + return ''.format(self.val) + + def __str__(self): + """Node class string printout.""" + return 'Node Val: {}'.format(self.val) + +class Queue: + def __init__(self, iter=[]): + self.front = None + self.back = None + self._length = 0 + + if not isinstance(iter, (list, dict, tuple)): + """ check for iterable """ + raise TypeError('It is not iterable.') + for i in iter: + self.enqueue(i) + + def enqueue(self, val): + """ add a value, increase size by 1""" + node = Node(val) + if self._length == 0: + self.front = self.back = node + self._length += 1 + return node + self.back.next = node + self.back = node + self._length += 1 + return node + + def dequeue(self): + """ remove node from the front of queue """ + if self._length == 0: + raise IndexError('You cannot dequeue() when front is empty') + + temp = self.front + self.front = temp.next + self._length -= 1 + return temp + +class KTree: + """Ktree class definition.""" + + def __init__(self): + """Create an instance of KTree object.""" + self.root = None + + def __repr__(self): + """Ktree class representation.""" + return ''.format(self.root.val) + + def __str__(self): + """Ktree class string printout.""" + return 'KTree Root Val: {}'.format(self.root.val) + + def pre_order(self, operation): + """Ktree pre_order traversal.""" + def _walk(node=None): + if node is None: + return + + operation(node) + + for child in node.children: + _walk(child) + + _walk(self.root) + + def post_order(self, operation): + """Ktree post_order traversal.""" + def _walk(node=None): + if node is None: + return + + for child in node.children: + _walk(child) + + operation(node) + + _walk(self.root) + + def breadth_first_traversal(self, operation): + """Ktree breadth_first_traversal.""" + queue = Queue() + queue.enqueue(self.root) + while queue._length > 0: + current = queue.dequeue() + operation(current) + for child in current.children: + queue.enqueue(child) + + def insert(self, val, parent=None): + """Insert a value at first instance of given parent.""" + if parent is None: + if self.root is None: + self.root = Node(val) + return self.root + raise ValueError('parent node is none.') + + node = Node(val) + + def _walk(curr=None): + if curr is None: + return + + if curr.val == parent: + curr.children.append(node) + return + + for child in curr.children: + _walk(child) + if node in child.children: + return + _walk(self.root) \ No newline at end of file From ad9583d86b5166641dcf7f6c39d959991d356299 Mon Sep 17 00:00:00 2001 From: MsDiala Date: Fri, 8 Jan 2021 19:48:27 +0200 Subject: [PATCH 3/3] done --- .../challenges/merge_sort/merge_sort.py | 37 +++++++++++ .../challenges/merge_sort/read.md | 63 +++++++++++++++++++ tests/challenges/test_merge_sort.py | 43 +++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 data_structures_and_algorithms/challenges/merge_sort/merge_sort.py create mode 100644 data_structures_and_algorithms/challenges/merge_sort/read.md create mode 100644 tests/challenges/test_merge_sort.py diff --git a/data_structures_and_algorithms/challenges/merge_sort/merge_sort.py b/data_structures_and_algorithms/challenges/merge_sort/merge_sort.py new file mode 100644 index 0000000..0554b59 --- /dev/null +++ b/data_structures_and_algorithms/challenges/merge_sort/merge_sort.py @@ -0,0 +1,37 @@ +def merge_sort(arr): + n = len(arr) + # split the array in half + if n == 1: + return arr + if n == 0: + return "Not a valid input" + if n > 1: + mid = n//2 + left = arr[:mid] + right = arr[mid:] + # sort the left side + merge_sort(left) + # sort the right side + merge_sort(right) + # sort them together in the correct order + i = j = k = 0 + while i < len(left) and j < len(right): + if left[i] < right[j]: + arr[k] = left[i] + i += 1 + else: + arr[k] = right[j] + j += 1 + k += 1 + + # Checking if any element was left + while i < len(left): + arr[k] = left[i] + i += 1 + k += 1 + + while j < len(right): + arr[k] = right[j] + j += 1 + k += 1 + return arr \ No newline at end of file diff --git a/data_structures_and_algorithms/challenges/merge_sort/read.md b/data_structures_and_algorithms/challenges/merge_sort/read.md new file mode 100644 index 0000000..e405515 --- /dev/null +++ b/data_structures_and_algorithms/challenges/merge_sort/read.md @@ -0,0 +1,63 @@ + +

Merge Sort

+ +

About :

+
+Merge Sort is a Divide &Conquer Alogrithm.
+
+It divides input array in two halves,calls itself for the two halves.
+the merge(arr,l,m,r) is key process that assumes that arr{i....m} and arr{m+1...r}
+are sorted and merge the two sorted is sub arrays into one.
+ 
+ +

What do you mean by " Divide and Conquer approach"?

+ +
+A Divide-and-conquer Algorithm works by recursively breaking down a problem into two or more 
+sub-problems of the same or related type, until these become simple enough to be solved directly. 
+
+The solutions to the sub-problems are then combined to give a solution to the original problem.
+
+The array is split in half and the process is repeated with each half until each half is of size 1 or 0. 
+
+The array of size 1 is trivially sorted.
+
+Now the two sorted arrays are combined into one big array. And this is continued until all the elements are combined and the array is sorted. 
+
+

Time complexity

+ +The algorithm works in O(n.logn). This is because the list is being split in log(n) calls and the merging process takes linear time in each call. + +Auxiliary Space: O(n) + +Algorithmic Paradigm: Divide and Conquer + +Sorting In Place: No in a typical implementation + +Stable: Yes + + +

Applications :

+
+1) Merge Sort is useful for sorting linked lists in O(nLogn) time.
+2)Inversion Count Problem
+3)Used in External Sorting
+
+ + +

Pseudocode :

+
+MergeSort(arr[], l,  r)
+If r > l
+     1. Find the middle point to divide the array into two halves:  
+             middle m = (l+r)/2
+     2. Call mergeSort for first half:   
+             Call mergeSort(arr, l, m)
+     3. Call mergeSort for second half:
+             Call mergeSort(arr, m+1, r)
+     4. Merge the two halves sorted in step 2 and 3:
+             Call merge(arr, l, m, r)
+             
+             
+
+
diff --git a/tests/challenges/test_merge_sort.py b/tests/challenges/test_merge_sort.py new file mode 100644 index 0000000..cf05bee --- /dev/null +++ b/tests/challenges/test_merge_sort.py @@ -0,0 +1,43 @@ +from data_structures_and_algorithms.merge_sort.merge_sort import merge_sort + + +def test_zero(): + z = [] + actual = merge_sort(z) + expected = "Not a valid input" + assert actual == expected + + +def test_one(): + z = [1] + actual = merge_sort(z) + expected = [1] + assert actual == expected + + +def test_many(): + z = [8, 4, 23, 42, 16, 15] + actual = merge_sort(z) + expected = [4, 8, 15, 16, 23, 42] + assert actual == expected + + +def test_many1(): + z = [20, 18, 12, 8, 5, -2] + actual = merge_sort(z) + expected = [-2, 5, 8, 12, 18, 20] + assert actual == expected + + +def test_many2(): + z = [5, 12, 7, 5, 5, 7] + actual = merge_sort(z) + expected = [5, 5, 5, 7, 7, 12] + assert actual == expected + + +def test_many3(): + z = [2, 3, 5, 7, 13, 11] + actual = merge_sort(z) + expected = [2, 3, 5, 7, 11, 13] + assert actual == expected \ No newline at end of file