pytudes

June 11, 2026 · View on GitHub

Peter Norvig
MIT License
2015-2026

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, for perfecting particular programming skills.

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

For each notebook you can hover on the title to see a description, or click the title to view on github, or click one of the letters in the left column to open the notebook on colab or nbviewer.

OpenYearNew
co nb2026Approximating Pi with a Fraction
co nb2026Did you solve it? R y clvr ngh t rd ths sntnc?
co nb2026Project Euler #3: Largest prime factor
co nb2026Truncatable Primes
co nb2025Advent of Code 2025
co nb2025Advent of Code 2025: AI LLM Edition
OpenYearProgramming Examples
co nb2022AlphaCode Automated Programming
co nb2026Approximating Pi with a Fraction
co nb2022The Babylonian Number System
co nb2018Beal's Conjecture Revisited
co nb2020Bicycling Statistics
co nb2018Can't Stop
co nb2019Chaos with Triangles
co nb2017Conway's Game of Life
co nb2020Generating and Solving Mazes
co nb2024The Languages of English, Math, and Programming
co nb2021Mel's Konane Board
co nb2020Photo Focal Lengths
co nb2018Pickleball Tournament
co nb2017Project Euler Utilities
co nb2022Selecting Names from a Menu
co nb2020Tracking Polls: Electoral Votes
OpenYearAdvent of Code
co nb2025Advent of Code 2025: AI LLM Edition
co nb2025Advent of Code 2025
co nb2024Advent of Code 2024
co nb2023Advent of Code 2023
co nb2022Advent of Code 2022
co nb2021Advent of Code 2021
co nb2020Advent of Code 2020
co nb2018Advent of Code 2018
co nb2017Advent of Code 2017
co nb2016Advent of Code 2016
co nb2022Advent of Code Utilities
OpenYearProbability and Uncertainty
co nb2019Effectiveness of Language Models
co nb2018A Concrete Introduction to Probability
co nb2016Probability, Paradox, and the Reasonable Person Principle
co nb2020Estimating Probabilities with Simulations
co nb2023The Diamond Game: A Probability Puzzle
co nb2019The Devil and the Coin Flip Game
co nb2020Dice Baseball
co nb2018Economics Simulation
co nb2024Overtime in American Football
co nb2012Poker Hand Ranking
co nb2020The Unfinished Game .... of Risk
co nb2019WWW: Who Will Win (NBA Title)?
OpenYearLogic and Number/Counting Puzzles
co nb2024Counting Cluster Sizes in Paint by Numbers
co nb2014Cryptarithmetic
co nb2018Euler's Sum of Powers Conjecture
co nb2020Four 4s, Five 5s, and Countdowns
co nb2020How to Count Things
co nb2021KenKen (Sudoku-like Puzzle)
co nb2024Number Bracelets Game
co nb2026Project Euler #3: Largest prime factor
co nb2019Pairing Socks
co nb2018Sicherman Dice
co nb2014Sol Golomb's Rectangle Puzzle
co nb2024Stubborn number endings
co nb2021Star Battle (Sudoku-like Puzzle)
co nb2006Sudoku
co nb2021Sudoku: 200,000 puzzles/second in Java
co nb2020Square Sum Puzzle
co nb2020When is Cheryl's Birthday?
co nb2015When Cheryl Met Eve: A Birthday Story
co nb2024LLMs, Theory of Mind, and Cheryl's Birthday
co nb2015xkcd 1313: Regex Golf
co nb2015xkcd 1313: Regex Golf (Part 2: Infinite Problems)
OpenYearWord Puzzles
co nb2020Boggle / Inverse Boggle
co nb2020Chemical Element Spelling
co nb2026Did you solve it? R y clvr ngh t rd ths sntnc?
co nb2020Equilength Numbers: FOUR = 4
co nb2017Gesture Typing
co nb2017Ghost: A Word game
co nb2018How to Do Things with Words: NLP in Python
co nb2015Let's Code About Bike Locks
co nb2023One Letter Off
co nb2017Scrabble: Refactoring a Crossword Game Program
co nb2020Spelling Bee
co nb2017Translating English into Propositional Logic
co nb2020Wordle, Evil Wordle, Antiwordle, and Jotto
co nb2022Winning Wordle
co nb2017World's Longest Palindrome
co nb2020World's Shortest Portmantout Word
co nb2018xkcd 1970: Name Dominoes
OpenYearThe Riddler (from 538)
co nb2022Anigrams: Word Chains
co nb2017Battle Royale
co nb2021Climbing Wall
co nb2021CrossProduct
co nb2020Flipping Cards; A Guessing Game
co nb2019Lottery
co nb2019How Many Soldiers to Beat the Night King?
co nb2017Misanthropic Neighbors
co nb2018Properly Organized Card Hands
co nb2021Race Track
co nb2021Split the States
co nb2020Tour de 538
co nb2020Weighing Twelve Balls
co nb2020War. What is it Good For?
OpenYearComputer Science Algorithms and Concepts
co nb2017BASIC Interpreter
co nb2017Convex Hull Problem
co nb2023Docstring Fixpoint Theory
co nb2020Stable Matching Problem
co nb2017Symbolic Algebra, Simplification, and Differentiation
co nb2017Snobol: Bad Grade, Good Experience
co nb2018Traveling Salesperson Problem
co nb2026Truncatable Primes

Index of Python Files

FileDescriptionDocumentation
beal.pySearch for counterexamples to Beal's Conjecturedocumentation
docex.pyAn obsolete framework for running unit tests, similar to doctest
ibol.pyAn Exercise in Species Barcodingdocumentation
lettercount.pyConvert Google Ngram Counts to Letter Countsdocumentation
lis.pyLisp Interpreter written in Pythondocumentation
lispy.pyEven Better Lisp Interpreter written in Pythondocumentation
lispytest.pyTests for Lisp Interpreters
pal.pyFind long palindromesdocumentation
pal2.pyFind longer palindromesdocumentation
pal3.pyFind even longer palindromesdocumentation
pytudes.pyPre-process text to generate this README.md file.
py2html.pyPretty-printer to format Python files as html
SET.pyAnalyze the card game SETdocumentation
spell.pySpelling correctordocumentation
sudoku.pyProgram to solve sudoku puzzlesdocumentation
testaccum.pyTests for my failed Python accumulation display proposaldocumentation
yaptu.pyYet Another Python Templating Utility

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." - 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."
  • [What code samples should programmers read?] "Anything else implemented by Norvig, he's one of the best programmers that I've had the pleasure of reading code from." - jacquesm on 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 [0] 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