Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
32c901d
Add Josephus problem example
gjbex Sep 24, 2021
55d5f91
Add checkpoint directory to gitignore
gjbex Sep 24, 2021
44cacf8
Add Welford algorithm example
gjbex Sep 28, 2021
d585ff0
Add generation example
gjbex Sep 29, 2021
cfd3e90
Fix typo in file name
gjbex Sep 29, 2021
e8dceef
Fix algorithm
gjbex Sep 29, 2021
6082313
Add survival example
gjbex Sep 30, 2021
678eca4
Add alternative implementations for Josephus problem
gjbex Nov 13, 2021
791f00a
Add visualization
gjbex Nov 13, 2021
8cd7e69
Add dice throwing example
gjbex Dec 9, 2021
310a966
Add Kaprekar constant example
gjbex Dec 9, 2021
0055bc1
Add Kaprekar example
gjbex Dec 14, 2021
1c7da25
Add d'Hondt hethod example
gjbex Dec 16, 2021
648e2ad
Add example implementing Condorcet voting example
gjbex Dec 17, 2021
1ecc301
Merge branch 'development' of github.com:gjbex/Python-for-programmers…
gjbex Dec 17, 2021
ae3a5b8
Add structural matching example
gjbex Mar 27, 2022
6b2dedc
Add remark on operator module use
gjbex Mar 27, 2022
1e862bf
Add some comments
gjbex Mar 27, 2022
e9bc9c3
Add money changing example (dynamic programming)
gjbex May 20, 2022
8233a71
Add environment file
gjbex May 20, 2022
ae009c5
Add island example
gjbex May 22, 2022
d49860a
Define Python 3.10 environment
gjbex May 22, 2022
669a853
Add hairiness example
gjbex May 29, 2022
8d2fa6a
Add word chain example
gjbex Jun 17, 2022
dbb471e
Add gitignore
gjbex Jun 17, 2022
f31621e
Merge branch 'development' of github.com:gjbex/Python-for-programmers…
gjbex Jun 17, 2022
433c7ad
Add some examples of unexpected Python behavior
gjbex Jul 12, 2022
c4e8e37
Fix file permissions
gjbex Jul 8, 2022
e7dcb61
Add examples of dynamic programming with memoization
gjbex Jul 12, 2022
c78e975
Add 100 prisoners example
gjbex Jul 13, 2022
d1bf6a7
Add some one-liner implementations
gjbex Aug 2, 2022
b3b6a1a
Add README
gjbex Aug 2, 2022
de21b5f
Add note of caution
gjbex Aug 3, 2022
53d2da6
Add regular expression and set matching examples
gjbex Aug 3, 2022
1fef2ed
Add non-trivial match use cases
gjbex Aug 3, 2022
96dbf37
Add file with random exercises
gjbex Oct 3, 2022
6c7c91b
Add magic square example
gjbex May 3, 2023
153e96e
Add description and comments
gjbex May 4, 2023
3f363df
Remove explicit version for Python to get the latest
gjbex May 4, 2023
9b2a99b
Add editor files and checkpoint diretories
gjbex May 4, 2023
3fbb36a
Add backtracking example (knight's tour)
gjbex May 9, 2023
fcb0298
Add performance figures
gjbex May 11, 2023
4232ce8
Fix title
gjbex May 9, 2023
c3b0cae
Add initial implementation of Wansdorff's algorithm
gjbex May 12, 2023
6e62a8e
Add Wansdorff's algorithm implementation and benchmarks
gjbex May 12, 2023
f6a8f58
Add flatten example
gjbex May 12, 2023
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# direnv configuration file
.envrc

# editor backup files
*~
*.bak

# checkpoint directory
.ipynb_checkpoints/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Python-for-programmers
# Python for programmers

Repository for participants of the "Python for programmers" training
8 changes: 8 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: python_for_programmers
channels:
- defaults
dependencies:
- python
- jupyterlab
- matplotlib
prefix: /home/gjb/miniconda3/envs/python_for_programmers
144 changes: 144 additions & 0 deletions python_for_programmers_linux64_conda_specs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
@EXPLICIT
https://repo.anaconda.com/pkgs/main/linux-64/_libgcc_mutex-0.1-main.conda
https://repo.anaconda.com/pkgs/main/linux-64/blas-1.0-mkl.conda
https://repo.anaconda.com/pkgs/main/linux-64/ca-certificates-2022.4.26-h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/intel-openmp-2021.4.0-h06a4308_3561.conda
https://repo.anaconda.com/pkgs/main/linux-64/ld_impl_linux-64-2.38-h1181459_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/libstdcxx-ng-11.2.0-h1234567_0.conda
https://repo.anaconda.com/pkgs/main/noarch/tzdata-2022a-hda174b7_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libgomp-11.2.0-h1234567_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/mkl-2021.4.0-h06a4308_640.conda
https://repo.anaconda.com/pkgs/main/linux-64/_openmp_mutex-5.1-1_gnu.conda
https://repo.anaconda.com/pkgs/main/linux-64/libgcc-ng-11.2.0-h1234567_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/brotli-1.0.9-he6710b0_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/bzip2-1.0.8-h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/expat-2.4.4-h295c915_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/giflib-5.2.1-h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/icu-58.2-he6710b0_3.conda
https://repo.anaconda.com/pkgs/main/linux-64/jpeg-9e-h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libffi-3.3-he6710b0_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/libsodium-1.0.18-h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libuuid-1.0.3-h7f8727e_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/libwebp-base-1.2.2-h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libxcb-1.15-h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/lz4-c-1.9.3-h295c915_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/ncurses-6.3-h7f8727e_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/openssl-1.1.1o-h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pcre-8.45-h295c915_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/xz-5.2.5-h7f8727e_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/zlib-1.2.12-h7f8727e_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/glib-2.69.1-h4ff587b_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/libpng-1.6.37-hbc83047_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libxml2-2.9.12-h74e7548_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/readline-8.1.2-h7f8727e_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/tk-8.6.11-h1ccaba5_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/zeromq-4.3.4-h2531618_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/zstd-1.5.2-ha4553b6_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/dbus-1.13.18-hb2f20db_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/freetype-2.11.0-h70c0345_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/gstreamer-1.14.0-h28cd5cc_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/libtiff-4.2.0-h2818925_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/sqlite-3.38.3-hc218d9a_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/fontconfig-2.13.1-h6c09931_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/gst-plugins-base-1.14.0-h8213a91_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/lcms2-2.12-h3be6417_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libwebp-1.2.2-h55f646e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/python-3.10.4-h12debd9_0.tar.bz2
https://repo.anaconda.com/pkgs/main/noarch/attrs-21.4.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/backcall-0.2.0-pyhd3eb1b0_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/certifi-2022.5.18.1-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/charset-normalizer-2.0.4-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/cycler-0.11.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/debugpy-1.5.1-py310h295c915_0.conda
https://repo.anaconda.com/pkgs/main/noarch/decorator-5.1.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/defusedxml-0.7.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/entrypoints-0.4-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/executing-0.8.3-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/idna-3.3-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/ipython_genutils-0.2.0-pyhd3eb1b0_1.conda
https://repo.anaconda.com/pkgs/main/noarch/json5-0.9.6-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/kiwisolver-1.3.1-py310h295c915_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/markupsafe-2.0.1-py310h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/mistune-0.8.4-py310h7f8727e_1000.conda
https://repo.anaconda.com/pkgs/main/noarch/munkres-1.1.4-py_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/nest-asyncio-1.5.5-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pandocfilters-1.5.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/parso-0.8.3-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pickleshare-0.7.5-pyhd3eb1b0_1003.conda
https://repo.anaconda.com/pkgs/main/linux-64/pillow-9.0.1-py310h22f2fdc_0.conda
https://repo.anaconda.com/pkgs/main/noarch/prometheus_client-0.13.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/ptyprocess-0.7.0-pyhd3eb1b0_2.conda
https://repo.anaconda.com/pkgs/main/noarch/pure_eval-0.2.2-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pycparser-2.21-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pygments-2.11.2-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pyparsing-3.0.4-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pyrsistent-0.18.0-py310h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pysocks-1.7.1-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/python-fastjsonschema-2.15.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pytz-2021.3-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pyzmq-22.3.0-py310h295c915_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/qt-5.9.7-h5867ecd_1.conda
https://repo.anaconda.com/pkgs/main/noarch/send2trash-1.8.0-pyhd3eb1b0_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/sip-4.19.13-py310h295c915_0.conda
https://repo.anaconda.com/pkgs/main/noarch/six-1.16.0-pyhd3eb1b0_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/sniffio-1.2.0-py310h06a4308_1.conda
https://repo.anaconda.com/pkgs/main/noarch/soupsieve-2.3.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/testpath-0.5.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/tornado-6.1-py310h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/noarch/traitlets-5.1.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/typing_extensions-4.1.1-pyh06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/wcwidth-0.2.5-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/webencodings-0.5.1-py310h06a4308_1.conda
https://repo.anaconda.com/pkgs/main/noarch/wheel-0.37.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/anyio-3.5.0-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/asttokens-2.0.5-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/babel-2.9.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/beautifulsoup4-4.11.1-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/cffi-1.15.0-py310hd667e15_1.conda
https://repo.anaconda.com/pkgs/main/noarch/fonttools-4.25.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jedi-0.18.1-py310h06a4308_1.conda
https://repo.anaconda.com/pkgs/main/noarch/jinja2-3.0.3-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jsonschema-4.4.0-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jupyter_core-4.10.0-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/jupyterlab_pygments-0.1.2-py_0.conda
https://repo.anaconda.com/pkgs/main/noarch/matplotlib-inline-0.1.2-pyhd3eb1b0_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/mkl-service-2.4.0-py310h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/noarch/packaging-21.3-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pexpect-4.8.0-pyhd3eb1b0_3.conda
https://repo.anaconda.com/pkgs/main/noarch/prompt-toolkit-3.0.20-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pyqt-5.9.2-py310h295c915_6.conda
https://repo.anaconda.com/pkgs/main/noarch/python-dateutil-2.8.2-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/setuptools-61.2.0-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/terminado-0.13.1-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/typing-extensions-4.1.1-hd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/websocket-client-0.58.0-py310h06a4308_4.conda
https://repo.anaconda.com/pkgs/main/linux-64/argon2-cffi-bindings-21.2.0-py310h7f8727e_0.conda
https://repo.anaconda.com/pkgs/main/noarch/bleach-4.1.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/brotlipy-0.7.0-py310h7f8727e_1002.conda
https://repo.anaconda.com/pkgs/main/linux-64/cryptography-37.0.1-py310h9ce1e76_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jupyter_client-7.2.2-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/nbformat-5.3.0-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/numpy-base-1.22.3-py310h9585f30_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pip-21.2.4-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/stack_data-0.2.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/argon2-cffi-21.3.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/ipython-8.3.0-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/nbclient-0.5.13-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pyopenssl-22.0.0-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/ipykernel-6.9.1-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/nbconvert-6.4.4-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/urllib3-1.26.9-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/jupyter_server-1.13.5-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/notebook-6.4.11-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/requests-2.27.1-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jupyterlab_server-2.12.0-py310h06a4308_0.conda
https://repo.anaconda.com/pkgs/main/noarch/nbclassic-0.3.5-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/noarch/jupyterlab-3.3.2-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/matplotlib-3.5.1-py310h06a4308_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/matplotlib-base-3.5.1-py310ha18d171_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/mkl_fft-1.3.1-py310hd6ae3a3_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/mkl_random-1.2.2-py310h00e6091_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/numpy-1.22.3-py310hfa59a62_0.conda
1 change: 1 addition & 0 deletions source_code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ipynb_checkpoints/
38 changes: 38 additions & 0 deletions source_code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# # Source code

Code samples for in the presentation, or provided as extra material, illustrating
certain subtle points.

## What is it?

1. `coins.ipynb`: change a sum of money into coinage, comparing a brute force
approach to recursion, memoization and dynamic programming.
1. `condorcet_voting.ipynb`: implementation of Condorcet voting.
1. `counterintuiive.ipynb`: some example of counter-intuitive performance results.
1. `dHondt_method.ipynb`: assigning seats in gremia according to the number of votes.
1. `dice.ipynb`: modelling throwing two dice and visualizng the results.
1. `dynamic_programming.ipynb`: some illustrations of using memoization and
dynamic programming to efficiently solve mathematical problems.
1. generations.ipynb`: searching for the most recent common ancestor and the
identical ancestor generation.
1. `hundred_prisoners.ipynb`: implementation of the solution to the "hundred
prisoners` puzzle.
1. `islands.ipynb`: identify "islands" in a 2D sea.
1. `josephus.ipynb`: solving the Josephus problem; various implementations are
compared for performance.
1. `kaprekar.ipynb`: compute the Kaprekar number.
1. `neighborhoods.ipynb` and '`game.png`: computing the hairiness of neighborhoods.
1. `one_liners.ipynb`: implementatin of a variety of problems as Python one-liners;
this is for sport, not production.
1. `survival.ipynb`: study populatoin sizes in terms of procreation rates.
1. `structural_pattern_matching.ipynb`: example of structural pattern matching
(requires Python 3.10+).
1. `welford_algorithm.ipynb`: implementation of WellFord's algorithm to compute an
estimate for the standard deviation of a data stream.
1. `word_chains.ipynb`: create word chains out of a list of words so that the first
letter of a word is the same as the last letter of the previous. Search for the
longest chain.
1. `knights_tour.ipynb`: example of using backtracking to solve the knight's tour
problem.
1. `flatten.ipynb`: `itertools.chain` may not flatten a data structure as you might
expect or want.
Loading