norvig/pytudes
حول
برامج Python، تكون عادةً قصيرة وذات صعوبة كبيرة، لإتقان مهارات محددة.
مشاريع أخرىالنمو المقاس للنجوم
- خلال 24 ساعة
- +٥
- خلال 7 أيام
- +١٠
- خلال 15 يومًا
- +١٩
- خلال شهر
- +٢٢
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلpytudes
"An étude (a French word meaning study) is an instrumental musical composition, usually short, of considerable difficulty, and designed to provide practice material for perfecting a particular musical skill." — Wikipedia
This project contains pytudes—Python programs, usually short, providing practice pieces for perfecting particular programming prowess.
Who is this for?
To continue the musical analogy, some people think of programming like Spotify: they want to know how to install the app, find a good playlist, and hit the "play" button; after that they don't want to think about it. There are plenty of other tutorials that will tell you how to do the equivalent of that for various programming tasks—this one won't help. But if you think of programming like playing the piano—a craft that can take years to perfect—then I hope this collection can help.
Index of Jupyter (IPython) Notebooks
Click a title to see a notebook on GitHub, or click the
icon next to it to run it in Colab
.
On a desktop, hover over a title to see a more complete description.
🆕 New in 2026
- Advent of Code
| Strachey's 1966 CPL Checkers Program
| xkcd #173: Optimal Movie Seating
| Approximating Pi with a Fraction
| Integer Palindromes
| Largest prime factor
| Provably Shortest Portmantout Word
| Truncatable Primes![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Project Euler:
by me
| by Claude Fable
| by Claude Opus
| by Kimi![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
🤖 Large Language Models
- Coding with AI:
AlphaCode automated programming (2022)
| The languages of English, math, and programming (2024)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Language models:
Effectiveness of language models (2019)
| How to do things with words (2018)
| One letter off (2023)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- See also: Project Euler by LLMs · Advent of Code 2025 by LLMs · LLMs and Cheryl's Birthday (2024) · Integer palindromes (human vs. LLM) (2026) · Provably shortest portmantout (found by AI) (2026)
🎲 Probability and Uncertainty
- Probability:
A concrete introduction (2018)
| Paradoxes and the reasonable person principle (2016)
| Estimating with simulations (2020)
| How to count things (2020)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Games of chance:
Poker hand ranking (2012)
| The unfinished game of Risk (2020)
| The Devil and the coin flip (2019)
| The diamond game (2023)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Sports:
Who will win the NBA title? (2019)
| Overtime in American football (2024)
| Dice baseball (2020)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Simulations:
Economics simulation (2018)
| Cluster sizes in paint by numbers (2024)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
🎄 Advent of Code (Problems from adventofcode.com)
- By year:
2016
| 2017
| 2018
| 2020
| 2021
| 2022
| 2023
| 2024
| 2025
| 2026![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Extras:
2025: solved by AI LLMs
| Utility functions (2022)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
🌉 Project Euler (Problems from projecteuler.net)
- Problems #1–100:
by me (2026)
| by Claude Fable (2026)
| by Claude Opus (2026)
| by Kimi (2026)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- For beginners:
Largest prime factor (#3) (2026)
![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
🧩 Logic and Number Puzzles
- Cheryl's Birthday:
When is Cheryl's birthday? (2020)
| When Cheryl met Eve (2015)
| LLMs and theory of mind (2024)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Arithmetic puzzles:
Four 4s, five 5s, and countdowns (2020)
| Cryptarithmetic (2014)
| Square sum chains (2020)
| Number bracelets (2024)
| Sicherman dice (2018)
| Sol Golomb's rectangle puzzle (2014)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Number theory:
Approximating pi with a fraction (2026)
| Truncatable primes (2026)
| Stubborn number endings (2024)
| The Babylonian number system (2022)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Famous conjectures:
Beal's conjecture revisited (2018)
| Euler's sum of powers conjecture (2018)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
🔢 Grid Puzzles and Board Games
- Sudoku:
in Python (2006)
| in Java: 400,000 puzzles/second (2021)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Sudoku-like puzzles:
KenKen (2021)
| Star Battle (2021)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Board games:
Can't Stop (2018)
| Mel's Konane board (2021)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
🔠 Word Games and Puzzles
- Wordle:
Wordle, Evil Wordle, Antiwordle, and Jotto (2020)
| Winning Wordle (2022)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Palindromes:
World's longest palindrome (2017)
| Integer palindromes (2026)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Portmantout:
Portmantout words (2020)
| AI Provably shortest (2026)
| Claude's Provably shortest (2026)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Scrabble:
Refactoring a Scrabble Player (2017)
| Maximum Scoring Scrabble Board![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Word games:
Boggle / inverse Boggle (2020)
| Ghost (2017)
| NYT Spelling Bee (2020)
| Gesture typing (2017)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Wordplay:
Chemical element spelling (2020)
| Equilength numbers: FOUR = 4 (2020)
| Let's code about bike locks (2015)
| R y clvr ngh t rd ths? (2026)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
🧠 The Riddler and xkcd
- The Riddler (FiveThirtyEight):
Anigrams (2022)
| Battle Royale (2017)
| Climbing wall (2021)
| CrossProduct (2021)
| Flipping cards (2020)
| Lottery (2019)
| The Night King (2019)
| Misanthropic neighbors (2017)
| Organized card hands (2018)
| Race track (2021)
| Split the states (2021)
| Tour de 538 (2020)
| Weighing twelve balls (2020)
| War (2020)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- xkcd:
Regex golf (#1313) (2015)
| Regex golf, part 2 (2015)
| Name dominoes (#1970) (2018)
| Movie Seating (#173)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
💻 Computer Science
- Interpreters and languages:
Lisp interpreter (2026)
| BASIC interpreter (2017)
| Symbolic algebra and differentiation (2017)
| Translating English into propositional logic (2017)
| Snobol: bad grade, good experience (2017)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Classic algorithms:
Traveling salesperson (2018)
| Convex hull (2017)
| Stable matching (2020)
| Making mazes (2020)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Software craft:
Docstring fixpoint theory (2023)
| Selecting names from a menu (2022)
| Scheduling a pickleball tournament (2018)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
📊 Data and Simulation
- Data visualization:
Bicycling statistics (2020)
| Photo focal lengths (2020)
| Tracking polls: electoral votes (2020)
| Pairing socks (2019)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
- Emergent patterns:
Conway's Game of Life (2017)
| Chaos with triangles (2019)![[colab]](https://colab.research.google.com/img/colab_favicon_256px.png)
Etudes for Programmers
I got the idea for the "etudes" part of the name from this 1978 book by Charles Wetherell that was very influential to me when I was first learning to program. I still have my copy, but it is now easier to find a pdf than a hard copy.

Reviews of pytudes
Here's what some people are saying about pytudes:
- "What I find interesting is how Peter builds bottom-up solutions using low-level utilities... Reading his code is educational. ... I don’t know of anyone who writes more idiomatic python than Norvig 🙂" – Jeremey Howard, co-founder of fast.ai and chief scientist at Kaggle
- "Everything I see from Peter Norvig is just always so incredibly well written and coded." — Jonathan, Hacker News
- "Peter Norvig is my go to recommendation when someone is interested in becoming better at solving day to day problems ... I feel his skill of dividing a problem into small pieces and expressing them in code in a natural way is unparalleled." — mikevin, Hacker News
- "I've never seen Peter Norvig choose anything but the most elegant and perfect data model for the problem at hand." — spoonjim, Hacker News
- "I just find Norvig's style of "functional Python" lovely in its own way (with noted disregard of Pep8 and other "best practices")" — raverbashing, Hacker News
- "You should check out Norvig's design of computer programs course on Udacity where he uses these kinds of puzzle programs to teach programming design concepts. It is a hard but really rewarding course. — nafizh, HN ACademy
- "Often enough I would think of something [a possible improvement[, but if you worked it out in detail there was some less-obvious reason the code was the way it was... All the code is pretty short, and it's not really 'production code', but it's enough to be an education in craftsmanship at every level. ... The work in the end looks pragmatic, but sort of an idealized pragmatism: you have to really want to produce your best work, to work that hard over it." – abecedarius, Hacker News
- "anything implemented by Norvig, he's one of the best programmers that I've had the pleasure of reading code from." – jacquesm, Hacker News
- "Everything I see from Peter Norvig is just always so incredibly well written and coded. Every year looking at his solutions for advent of code brings just so much learnings. Strongly recommend. - jyepin, Hacker News
- "I feel his skill of dividing a problem into small pieces and expressing them in code in a natural way is unparalleled." – mikevin, Hacker News
- "This is one of the best way to learn idiomatic python. Learn from the best! ... I was stunned by the quality of his code. I recommend this set of notebooks to anyone who think they need to improve their coding skills." – Vikram Kalabi, fast.ai forum
- "The common thread is Norvig’s programming style — clear, dense, idiomatic Python that uses the right data structures and expresses solutions at the right level of abstraction. The value of pytudes isn’t just the problems but the solutions. Norvig’s solutions are teaching artifacts: he writes code the way an experienced programmer thinks, not the way a beginner writes explanations. Reading how he solves a problem you’ve already solved yourself is often more instructive than solving a new problem, because you see what you could have done differently." – Ryan Orban, his blog
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…