diff --git a/.gitignore b/.gitignore index 0627767..2fec769 100644 --- a/.gitignore +++ b/.gitignore @@ -1,230 +1,230 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,windows,macos,linux -# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode,windows,macos,linux - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - - -# KDE directory preferences -.directory - -# .idea -.idea - -# .vscode -.vscode - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### macOS ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history - -### Windows ### -# Windows thumbnail cache files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,windows,macos,linux - -# Ignore csv + +# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,windows,macos,linux +# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode,windows,macos,linux + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + + +# KDE directory preferences +.directory + +# .idea +.idea + +# .vscode +.vscode + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,windows,macos,linux + +# Ignore csv *.csv \ No newline at end of file diff --git a/README.md b/README.md index 7da7e63..2f52fc7 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,48 @@ -# 1. Encuentra el par con la suma dada en el arreglo - -En un arreglo de enteros no ordenado, encuentra el par de la suma dadada. - -## Precondiciones -1. El arreglo solo contiene enteros. -2. El arreglo no esta ordenado. -3. Pueden existir uno o más pares que den el resultado de la suma, cualquier respuesta es correcta. -4. La entrada en un arreglo de enteros. - -## Poscondiciones -1. El resultado es también un arreglo con dos elementos, contiene el par de enteros que da como resultado la suma. - -## Instrucciones -1. Crea una rama con tu nombre de correo sin dominio en el repositorio, será donde se subirá tu ejercicio. -2. Analiza el problema, busca la solución más óptima en tiempo de ejecución y memoria utilizada. -3. Resuelve el problema en la funcion find_pair en el archivo con el mismo nombre. Es importante que no modifiques la firma de la función. Puedes agregar más funciones en el mismo archivo. -4. Sube tu respuesta antes del corte establecido a tu rama. -5. Prepara una explicación sobre tu respuesta donde debes de expresa tu algoritmo en notación big O. La expresión en big O debe de representar toda la función, explica como llegaste a la expresión final. - -### Ejemplo - -```python -# Input -array = [1,5,6,7,3,5] -sum = 10 - -# Output -[7,3] or [5,5] -``` - -## Puntos a calificar - -### Principales: -1. Tiempo d ejeccución. -2. Uso de memoria. - -### Secundarios: -1. Estilo de escritura de código acorde al lenguaje. -2. El correcto uso de las conveciones de nombres. -3. Legibilidad del código. Un buen código se explica solo. -4. La falta o exceso de comentarios. - -## Motivo para descalificar -1. Copiar el ejerccicio de algún compañero o cualquier otra fuente. -2. Utilizar librerías que resuelvan el problema. -3. No saber explicar como llegaron a la solución entregada. +# 1. Encuentra el par con la suma dada en el arreglo + +En un arreglo de enteros no ordenado, encuentra el par de la suma dadada. + +## Precondiciones +1. El arreglo solo contiene enteros. +2. El arreglo no esta ordenado. +3. Pueden existir uno o más pares que den el resultado de la suma, cualquier respuesta es correcta. +4. La entrada en un arreglo de enteros. + +## Poscondiciones +1. El resultado es también un arreglo con dos elementos, contiene el par de enteros que da como resultado la suma. + +## Instrucciones +1. Crea una rama con tu nombre de correo sin dominio en el repositorio, será donde se subirá tu ejercicio. +2. Analiza el problema, busca la solución más óptima en tiempo de ejecución y memoria utilizada. +3. Resuelve el problema en la funcion find_pair en el archivo con el mismo nombre. Es importante que no modifiques la firma de la función. Puedes agregar más funciones en el mismo archivo. +4. Sube tu respuesta antes del corte establecido a tu rama. +5. Prepara una explicación sobre tu respuesta donde debes de expresa tu algoritmo en notación big O. La expresión en big O debe de representar toda la función, explica como llegaste a la expresión final. + +### Ejemplo + +```python +# Input +array = [1,5,6,7,3,5] +sum = 10 + +# Output +[7,3] or [5,5] +``` + +## Puntos a calificar + +### Principales: +1. Tiempo d ejeccución. +2. Uso de memoria. + +### Secundarios: +1. Estilo de escritura de código acorde al lenguaje. +2. El correcto uso de las conveciones de nombres. +3. Legibilidad del código. Un buen código se explica solo. +4. La falta o exceso de comentarios. + +## Motivo para descalificar +1. Copiar el ejerccicio de algún compañero o cualquier otra fuente. +2. Utilizar librerías que resuelvan el problema. +3. No saber explicar como llegaron a la solución entregada. 4. No expresar en notación big O el algoritmo. \ No newline at end of file diff --git a/find_pair.py b/find_pair.py index ec957af..b4b6773 100644 --- a/find_pair.py +++ b/find_pair.py @@ -1,11 +1,32 @@ -# MédicoSoft 2020 -# 1. Encuentra el par con la suma dada en el arreglo -# Lee el README.md antes de comenzar - -def find_pair(array, sum) -> [1,2]: - """Arguents: - array -- unsorter array of integers - sum -- sum of pair of integers to find - Retorna: - array -- array of two elements with the integers of sum to find - """ \ No newline at end of file +# MédicoSoft 2020 +# 1. Encuentra el par con la suma dada en el arreglo +# Lee el README.md antes de comenzar + +def find_pair(array, sum) -> [1, 2]: + """Arguents: + array -- unsorter array of integers + sum -- sum of pair of integers to find + Retorna: + array -- array of two elements with the integers of sum to find + """ + difference = 0 + position_num2 = 0 + + for index, num in enumerate(array): + difference = sum - num + + try: + position_num2 = array.index(difference, (index+1), len(array)) + + return [num, array[position_num2]] + break + except: + pass + + return [0, 0] + + +result = find_pair([1, 5, 6, 7, 3, 5], 11) + +for num in result: + print(num, " ")