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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ Well worth reading:

<https://leetcode.com/problems/single-number-ii/discuss/43295/Detailed-explanation-and-generalization-of-the-bitwise-operation-method-for-single-numbers>

- **binary search**

<https://leetcode.com/problems/split-array-largest-sum/discuss/769701/Python-Clear-explanation-Powerful-Ultimate-Binary-Search-Template.-Solved-many-problems>

## More specific

- **Calculator Problems**

<https://leetcode.com/problems/basic-calculator-iii/discuss/113592/development-of-a-generic-solution-for-the-series-of-the-calculator-problems>

## Contact
recnac@foxmail.com
recnac@foxmail.com
212 changes: 212 additions & 0 deletions api/Gemini_API.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyN1p4g1NDK3HZAFJF2uZCeG",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/hashd2035/Algorithm_Templates/blob/master/api/Gemini_API.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "PE32UIdx0ISy",
"outputId": "657ea9af-c2e9-4205-fce6-8bbb95e40115"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'AIzaSyBf_48-Pgs9ia6yjFXiUV_cq3_jredo3Mc'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 2
}
],
"source": [
"from google.colab import userdata\n",
"userdata.get('gemini_apikey')"
]
},
{
"cell_type": "code",
"source": [
"!pip install --ignore-installed jedi apache-airflow"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "sYDY7_tf0h8s",
"outputId": "0b80d183-f78d-4e83-b76d-8e5505ff3d56"
},
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting charset-normalizer<4,>=2 (from requests<3,>=2.27.0->apache-airflow)\n",
" Using cached charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)\n",
"Collecting idna<4,>=2.5 (from requests<3,>=2.27.0->apache-airflow)\n",
" Using cached idna-3.7-py3-none-any.whl (66 kB)\n",
"Collecting urllib3<3,>=1.21.1 (from requests<3,>=2.27.0->apache-airflow)\n",
" Using cached urllib3-2.2.1-py3-none-any.whl (121 kB)\n",
"Collecting certifi>=2017.4.17 (from requests<3,>=2.27.0->apache-airflow)\n",
" Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)\n",
"Collecting greenlet!=0.4.17 (from sqlalchemy<2.0,>=1.4.36->apache-airflow)\n",
" Using cached greenlet-3.0.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (616 kB)\n",
"Collecting more-itertools>=9.0.0 (from apache-airflow-providers-common-sql->apache-airflow)\n",
" Using cached more_itertools-10.2.0-py3-none-any.whl (57 kB)\n",
"Collecting sqlparse>=0.4.2 (from apache-airflow-providers-common-sql->apache-airflow)\n",
" Using cached sqlparse-0.5.0-py3-none-any.whl (43 kB)\n",
"Collecting aiohttp>=3.9.2 (from apache-airflow-providers-http->apache-airflow)\n",
" Using cached aiohttp-3.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)\n",
"Collecting requests_toolbelt (from apache-airflow-providers-http->apache-airflow)\n",
" Using cached requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)\n",
"Collecting anyio (from httpx->apache-airflow)\n",
" Using cached anyio-4.3.0-py3-none-any.whl (85 kB)\n",
"Collecting httpcore==1.* (from httpx->apache-airflow)\n",
" Using cached httpcore-1.0.5-py3-none-any.whl (77 kB)\n",
"Collecting sniffio (from httpx->apache-airflow)\n",
" Using cached sniffio-1.3.1-py3-none-any.whl (10 kB)\n",
"Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx->apache-airflow)\n",
" Using cached h11-0.14.0-py3-none-any.whl (58 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-grpc==1.24.0 (from opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached opentelemetry_exporter_otlp_proto_grpc-1.24.0-py3-none-any.whl (18 kB)\n",
"Collecting opentelemetry-exporter-otlp-proto-http==1.24.0 (from opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached opentelemetry_exporter_otlp_proto_http-1.24.0-py3-none-any.whl (16 kB)\n",
"Collecting googleapis-common-protos~=1.52 (from opentelemetry-exporter-otlp-proto-grpc==1.24.0->opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached googleapis_common_protos-1.63.0-py2.py3-none-any.whl (229 kB)\n",
"Collecting grpcio<2.0.0,>=1.0.0 (from opentelemetry-exporter-otlp-proto-grpc==1.24.0->opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached grpcio-1.62.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.5 MB)\n",
"Collecting opentelemetry-exporter-otlp-proto-common==1.24.0 (from opentelemetry-exporter-otlp-proto-grpc==1.24.0->opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached opentelemetry_exporter_otlp_proto_common-1.24.0-py3-none-any.whl (17 kB)\n",
"Collecting opentelemetry-proto==1.24.0 (from opentelemetry-exporter-otlp-proto-grpc==1.24.0->opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached opentelemetry_proto-1.24.0-py3-none-any.whl (50 kB)\n",
"Collecting opentelemetry-sdk~=1.24.0 (from opentelemetry-exporter-otlp-proto-grpc==1.24.0->opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached opentelemetry_sdk-1.24.0-py3-none-any.whl (106 kB)\n",
"Collecting protobuf<5.0,>=3.19 (from opentelemetry-proto==1.24.0->opentelemetry-exporter-otlp-proto-grpc==1.24.0->opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached protobuf-4.25.3-cp37-abi3-manylinux2014_x86_64.whl (294 kB)\n",
"Collecting aiosignal>=1.1.2 (from aiohttp>=3.9.2->apache-airflow-providers-http->apache-airflow)\n",
" Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)\n",
"Collecting frozenlist>=1.1.1 (from aiohttp>=3.9.2->apache-airflow-providers-http->apache-airflow)\n",
" Using cached frozenlist-1.4.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (239 kB)\n",
"Collecting multidict<7.0,>=4.5 (from aiohttp>=3.9.2->apache-airflow-providers-http->apache-airflow)\n",
" Using cached multidict-6.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (124 kB)\n",
"Collecting yarl<2.0,>=1.0 (from aiohttp>=3.9.2->apache-airflow-providers-http->apache-airflow)\n",
" Using cached yarl-1.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (301 kB)\n",
"Collecting async-timeout<5.0,>=4.0 (from aiohttp>=3.9.2->apache-airflow-providers-http->apache-airflow)\n",
" Using cached async_timeout-4.0.3-py3-none-any.whl (5.7 kB)\n",
"Collecting pycparser (from cffi>=1.12->cryptography>=39.0.0->apache-airflow)\n",
" Using cached pycparser-2.22-py3-none-any.whl (117 kB)\n",
"Collecting exceptiongroup>=1.0.2 (from anyio->httpx->apache-airflow)\n",
" Using cached exceptiongroup-1.2.1-py3-none-any.whl (16 kB)\n",
"Collecting dnspython>=2.0.0 (from email-validator>=1.0.5->flask-appbuilder==4.4.1->apache-airflow-providers-fab>=1.0.2->apache-airflow)\n",
" Using cached dnspython-2.6.1-py3-none-any.whl (307 kB)\n",
"Collecting Babel>=2.3 (from Flask-Babel<3,>=1->flask-appbuilder==4.4.1->apache-airflow-providers-fab>=1.0.2->apache-airflow)\n",
" Using cached Babel-2.14.0-py3-none-any.whl (11.0 MB)\n",
"Collecting limits>=2.8 (from Flask-Limiter<4,>3->flask-appbuilder==4.4.1->apache-airflow-providers-fab>=1.0.2->apache-airflow)\n",
" Using cached limits-3.11.0-py3-none-any.whl (45 kB)\n",
"Collecting ordered-set<5,>4 (from Flask-Limiter<4,>3->flask-appbuilder==4.4.1->apache-airflow-providers-fab>=1.0.2->apache-airflow)\n",
" Using cached ordered_set-4.1.0-py3-none-any.whl (7.6 kB)\n",
"Collecting opentelemetry-semantic-conventions==0.45b0 (from opentelemetry-sdk~=1.24.0->opentelemetry-exporter-otlp-proto-grpc==1.24.0->opentelemetry-exporter-otlp->apache-airflow)\n",
" Using cached opentelemetry_semantic_conventions-0.45b0-py3-none-any.whl (36 kB)\n",
"Collecting importlib-resources>=1.3 (from limits>=2.8->Flask-Limiter<4,>3->flask-appbuilder==4.4.1->apache-airflow-providers-fab>=1.0.2->apache-airflow)\n",
" Using cached importlib_resources-6.4.0-py3-none-any.whl (38 kB)\n",
"Installing collected packages: unicodecsv, text-unidecode, pytz, lockfile, cron-descriptor, colorlog, zipp, wrapt, urllib3, uc-micro-py, tzdata, typing-extensions, termcolor, tenacity, tabulate, sqlparse, sniffio, six, setuptools, setproctitle, rpds-py, PyYAML, python-slugify, pyjwt, pygments, pycparser, psutil, protobuf, pluggy, pathspec, parso, packaging, ordered-set, opentelemetry-semantic-conventions, multidict, more-itertools, mdurl, markupsafe, lazy-object-proxy, itsdangerous, inflection, importlib-resources, idna, h11, grpcio, greenlet, google-re2, fsspec, frozenlist, exceptiongroup, docutils, dnspython, dill, configupdater, colorama, click, charset-normalizer, certifi, cachelib, blinker, Babel, attrs, async-timeout, argcomplete, yarl, WTForms, werkzeug, universal-pathlib, sqlalchemy, rfc3339-validator, requests, referencing, python-dateutil, python-daemon, prison, opentelemetry-proto, marshmallow, markdown-it-py, Mako, linkify-it-py, jinja2, jedi, importlib_metadata, httpcore, gunicorn, googleapis-common-protos, email-validator, deprecated, clickclick, cffi, asgiref, apispec, anyio, aiosignal, time-machine, sqlalchemy-utils, sqlalchemy-jsonfield, rich, requests_toolbelt, python-nvd3, opentelemetry-exporter-otlp-proto-common, opentelemetry-api, mdit-py-plugins, marshmallow-sqlalchemy, marshmallow-oneofschema, limits, jsonschema-specifications, httpx, flask, cryptography, croniter, alembic, aiohttp, rich-argparse, pendulum, opentelemetry-sdk, jsonschema, flask-wtf, Flask-SQLAlchemy, flask-session, flask-login, Flask-Limiter, Flask-JWT-Extended, flask-caching, Flask-Babel, opentelemetry-exporter-otlp-proto-http, opentelemetry-exporter-otlp-proto-grpc, flask-appbuilder, connexion, opentelemetry-exporter-otlp, apache-airflow-providers-common-sql, apache-airflow-providers-sqlite, apache-airflow-providers-smtp, apache-airflow-providers-imap, apache-airflow-providers-http, apache-airflow-providers-ftp, apache-airflow-providers-fab, apache-airflow-providers-common-io, apache-airflow\n",
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
"torch 2.2.1+cu121 requires nvidia-cublas-cu12==12.1.3.1; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-cuda-cupti-cu12==12.1.105; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-cuda-runtime-cu12==12.1.105; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-cudnn-cu12==8.9.2.26; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-cufft-cu12==11.0.2.54; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-curand-cu12==10.3.2.106; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-cusolver-cu12==11.4.5.107; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-cusparse-cu12==12.1.0.106; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-nccl-cu12==2.19.3; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"torch 2.2.1+cu121 requires nvidia-nvtx-cu12==12.1.105; platform_system == \"Linux\" and platform_machine == \"x86_64\", which is not installed.\n",
"sphinx 5.0.2 requires docutils<0.19,>=0.14, but you have docutils 0.21.2 which is incompatible.\n",
"gcsfs 2023.6.0 requires fsspec==2023.6.0, but you have fsspec 2024.3.1 which is incompatible.\n",
"ipython-sql 0.5.0 requires sqlalchemy>=2.0, but you have sqlalchemy 1.4.52 which is incompatible.\n",
"jupyter-server 1.24.0 requires anyio<4,>=3.1.0, but you have anyio 4.3.0 which is incompatible.\n",
"tensorflow 2.15.0 requires wrapt<1.15,>=1.11.0, but you have wrapt 1.16.0 which is incompatible.\n",
"tensorflow-metadata 1.14.0 requires protobuf<4.21,>=3.20.3, but you have protobuf 4.25.3 which is incompatible.\u001b[0m\u001b[31m\n",
"\u001b[0mSuccessfully installed Babel-2.14.0 Flask-Babel-2.0.0 Flask-JWT-Extended-4.6.0 Flask-Limiter-3.6.0 Flask-SQLAlchemy-2.5.1 Mako-1.3.3 PyYAML-6.0.1 WTForms-3.1.2 aiohttp-3.9.5 aiosignal-1.3.1 alembic-1.13.1 anyio-3.7.1 apache-airflow-2.9.0 apache-airflow-providers-common-io-1.3.1 apache-airflow-providers-common-sql-1.12.0 apache-airflow-providers-fab-1.0.4 apache-airflow-providers-ftp-3.8.0 apache-airflow-providers-http-4.10.1 apache-airflow-providers-imap-3.5.0 apache-airflow-providers-smtp-1.6.1 apache-airflow-providers-sqlite-3.7.1 apispec-6.6.1 argcomplete-3.3.0 asgiref-3.8.1 async-timeout-4.0.3 attrs-23.2.0 blinker-1.7.0 cachelib-0.9.0 certifi-2024.2.2 cffi-1.16.0 charset-normalizer-3.3.2 click-8.1.7 clickclick-20.10.2 colorama-0.4.6 colorlog-4.8.0 configupdater-3.2 connexion-2.14.2 cron-descriptor-1.4.3 croniter-2.0.5 cryptography-42.0.5 deprecated-1.2.14 dill-0.3.8 dnspython-2.6.1 docutils-0.18.1 email-validator-2.1.1 exceptiongroup-1.2.1 flask-2.2.5 flask-appbuilder-4.4.1 flask-caching-2.1.0 flask-login-0.6.3 flask-session-0.5.0 flask-wtf-1.2.1 frozenlist-1.4.1 fsspec-2024.3.1 google-re2-1.1 googleapis-common-protos-1.63.0 greenlet-3.0.3 grpcio-1.62.2 gunicorn-22.0.0 h11-0.14.0 httpcore-1.0.5 httpx-0.27.0 idna-3.7 importlib-resources-6.4.0 importlib_metadata-7.0.0 inflection-0.5.1 itsdangerous-2.2.0 jedi-0.19.1 jinja2-3.1.3 jsonschema-4.19.2 jsonschema-specifications-2023.12.1 lazy-object-proxy-1.10.0 limits-3.11.0 linkify-it-py-2.0.3 lockfile-0.12.2 markdown-it-py-3.0.0 markupsafe-2.1.5 marshmallow-3.21.1 marshmallow-oneofschema-3.1.1 marshmallow-sqlalchemy-0.28.2 mdit-py-plugins-0.4.0 mdurl-0.1.2 more-itertools-10.1.0 multidict-6.0.5 opentelemetry-api-1.24.0 opentelemetry-exporter-otlp-1.24.0 opentelemetry-exporter-otlp-proto-common-1.24.0 opentelemetry-exporter-otlp-proto-grpc-1.24.0 opentelemetry-exporter-otlp-proto-http-1.24.0 opentelemetry-proto-1.24.0 opentelemetry-sdk-1.24.0 opentelemetry-semantic-conventions-0.45b0 ordered-set-4.1.0 packaging-24.0 parso-0.8.4 pathspec-0.12.1 pendulum-3.0.0 pluggy-1.4.0 prison-0.2.1 protobuf-3.20.3 psutil-5.9.5 pycparser-2.22 pygments-2.16.1 pyjwt-2.8.0 python-daemon-3.0.1 python-dateutil-2.8.2 python-nvd3-0.16.0 python-slugify-8.0.4 pytz-2023.4 referencing-0.34.0 requests-2.31.0 requests_toolbelt-1.0.0 rfc3339-validator-0.1.4 rich-13.7.1 rich-argparse-1.4.0 rpds-py-0.18.0 setproctitle-1.3.3 setuptools-67.7.2 six-1.16.0 sniffio-1.3.1 sqlalchemy-1.4.52 sqlalchemy-jsonfield-1.0.2 sqlalchemy-utils-0.41.2 sqlparse-0.5.0 tabulate-0.9.0 tenacity-8.2.3 termcolor-2.4.0 text-unidecode-1.3 time-machine-2.14.1 typing-extensions-4.11.0 tzdata-2024.1 uc-micro-py-1.0.3 unicodecsv-0.14.1 universal-pathlib-0.2.2 urllib3-2.0.7 werkzeug-2.2.3 wrapt-1.14.1 yarl-1.9.4 zipp-3.18.1\n"
]
},
{
"output_type": "display_data",
"data": {
"application/vnd.colab-display-data+json": {
"pip_warning": {
"packages": [
"_distutils_hack",
"certifi",
"cffi",
"dateutil",
"google",
"jedi",
"parso",
"pkg_resources",
"psutil",
"pygments",
"setuptools",
"six"
]
},
"id": "144ab9f4ec8443fba7733022a296a48a"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"import airflow\n",
"airflow.__version__\n",
"\n",
"from airflow.models import DAG\n",
"vars(airflow)"
],
"metadata": {
"id": "5_vcvjU_07kE"
},
"execution_count": null,
"outputs": []
}
]
}