Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/Sprint-Challenge--Data-Structures-Python.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 47 additions & 4 deletions names/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,54 @@
names_2 = f.read().split("\n") # List containing 10000 names
f.close()

# Original Sol.---
# for name_1 in names_1:
# for name_2 in names_2:
# if name_1 == name_2:
# duplicates.append(name_1)

class BinarySearchTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None

def insert(self, value):
if value < self.value:
# Go left
if not self.left:
self.left = BinarySearchTree(value)
else:
self.left.insert(value)
else:
if not self.right:
self.right = BinarySearchTree(value)
else:
self.right.insert(value)

def contains(self, target):
if self.value == target:
return True

if target < self.value:
if not self.left:
return False
else:
return self.left.contains(target)
else:
if not self.right:
return False
else:
return self.right.contains(target)

# Set Duplicates
duplicates = []
for name_1 in names_1:
for name_2 in names_2:
if name_1 == name_2:
duplicates.append(name_1)
bst = BinarySearchTree(names_1[0])
for name in names_1:
bst.insert(name)
for name in names_2:
if bst.contains(name):
duplicates.append(name)

end_time = time.time()
print (f"{len(duplicates)} duplicates:\n\n{', '.join(duplicates)}\n\n")
Expand Down
10 changes: 8 additions & 2 deletions reverse/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@ def contains(self, value):
return False

def reverse_list(self):
# TO BE COMPLETED
pass
finished = None
current = self.head
while current is not None:
next = current.get_next()
current.set_next(finished)
finished = current
current = next
self.head = finished
24 changes: 23 additions & 1 deletion ring_buffer/ring_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,35 @@ def __init__(self, capacity):
self.storage = DoublyLinkedList()

def append(self, item):
pass
if self.storage.length < self.capacity:
self.storage.add_to_tail(item)
self.current = self.storage.head
elif self.storage.length == self.capacity:
to_delete = self.storage.head
self.storage.remove_from_head()
self.storage.add_to_tail(item)
if to_delete == self.current:
self.current = self.storage.tail

def get(self):
# Note: This is the only [] allowed
list_buffer_contents = []

# TODO: Your code here
int_node = self.current
list_buffer_contents.append(int_node.value)

if int_node.next is not None:
next_node = int_node.next
else:
next_node = self.storage.head

while next_node != int_node:
list_buffer_contents.append(next_node.value)
if next_node.next is not None:
next_node = next_node.next
else:
next_node = self.storage.head

return list_buffer_contents

Expand Down
2 changes: 2 additions & 0 deletions venv/Lib/site-packages/easy-install.pth
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./setuptools-40.8.0-py3.8.egg
./pip-19.0.3-py3.8.egg
73 changes: 73 additions & 0 deletions venv/Lib/site-packages/pip-19.0.3-py3.8.egg/EGG-INFO/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Metadata-Version: 1.2
Name: pip
Version: 19.0.3
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: [email protected]
License: MIT
Description: pip - The Python Package Installer
==================================

.. image:: https://img.shields.io/pypi/v/pip.svg
:target: https://pypi.org/project/pip/

.. image:: https://readthedocs.org/projects/pip/badge/?version=latest
:target: https://pip.pypa.io/en/latest

pip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.

Please take a look at our documentation for how to install and use pip:

* `Installation`_
* `Usage`_
* `Release notes`_

If you find bugs, need help, or want to talk to the developers please use our mailing lists or chat rooms:

* `Issue tracking`_
* `Discourse channel`_
* `User IRC`_

If you want to get involved head over to GitHub to get the source code and feel free to jump on the developer mailing lists and chat rooms:

* `GitHub page`_
* `Dev mailing list`_
* `Dev IRC`_

Code of Conduct
---------------

Everyone interacting in the pip project's codebases, issue trackers, chat
rooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_.

.. _package installer: https://packaging.python.org/en/latest/current/
.. _Python Package Index: https://pypi.org
.. _Installation: https://pip.pypa.io/en/stable/installing.html
.. _Usage: https://pip.pypa.io/en/stable/
.. _Release notes: https://pip.pypa.io/en/stable/news.html
.. _GitHub page: https://github.com/pypa/pip
.. _Issue tracking: https://github.com/pypa/pip/issues
.. _Discourse channel: https://discuss.python.org/c/packaging
.. _Dev mailing list: https://groups.google.com/forum/#!forum/pypa-dev
.. _User IRC: https://webchat.freenode.net/?channels=%23pypa
.. _Dev IRC: https://webchat.freenode.net/?channels=%23pypa-dev
.. _PyPA Code of Conduct: https://www.pypa.io/en/latest/code-of-conduct/

Keywords: distutils easy_install egg setuptools wheel virtualenv
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development :: Build Tools
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
Loading