Compare commits

..
9 Commits
Author SHA1 Message Date
Peter Norvig 19d2b079e2 Refactor questions about solutions in Sicherman Dice
Rephrase questions regarding solutions for composite and perfect square numbers.
2026-09-02 16:56:45 -07:00
Peter Norvig 708e128e23 Fix formatting for line 7 in Sicherman Dice table 2026-09-02 16:53:32 -07:00
Peter Norvig 062c0e7cd8 Fix formatting issues in Sicherman Dice table 2026-09-02 16:51:59 -07:00
Peter Norvig fa14771d00 Fix typos in Sicherman Dice notebook table layout 2026-09-02 16:50:34 -07:00
github-actions[bot] 1a6261e1b6 docs: auto-update README.md via pytudes.py 2026-09-02 23:15:09 +00:00
Peter Norvig 35a892134f Fix typo in find_newest and improve docstring
Updated docstring for clarity and corrected variable usage in sorting.
2026-09-02 16:14:55 -07:00
Peter Norvig e13dfe5705 Fix formatting in Golomb-Puzzle notebook 2026-09-02 15:48:50 -07:00
Peter Norvig 76bc8a483e Update GitHub Actions workflow for Python setup 2026-09-02 15:45:47 -07:00
Peter Norvig 504da3f655 Refactor find_newest to avoid duplicates in notebooks
Updated the logic in find_newest to prevent duplicate entries in the 'New' category.
2026-09-02 15:31:56 -07:00
5 changed files with 18 additions and 26 deletions

No files matched your search

+3 -9
View File
@@ -5,24 +5,19 @@ on:
paths: paths:
- 'py/pytudes.py' - 'py/pytudes.py'
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs: jobs:
build-and-update: build-and-update:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Added permissions to allow the bot to write to the repo
permissions: permissions:
contents: write contents: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v7
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: Run pytudes.py - name: Run pytudes.py
run: python py/pytudes.py run: python py/pytudes.py
@@ -32,6 +27,5 @@ jobs:
git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]" git config --local user.name "github-actions[bot]"
git add README.md git add README.md
# The || exit 0 prevents the workflow from failing if there are no changes
git commit -m "docs: auto-update README.md via pytudes.py" || exit 0 git commit -m "docs: auto-update README.md via pytudes.py" || exit 0
git push git push
+1 -2
View File
@@ -34,7 +34,6 @@ For each notebook you can hover on the title to see a description, or click the
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/TruncatablePrimes.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/TruncatablePrimes.ipynb) | 2026 | <a href="ipynb/TruncatablePrimes.ipynb" title="Prime numbers where you can remove digits and still get primes.">Truncatable Primes</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/TruncatablePrimes.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/TruncatablePrimes.ipynb) | 2026 | <a href="ipynb/TruncatablePrimes.ipynb" title="Prime numbers where you can remove digits and still get primes.">Truncatable Primes</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Advent-2025.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Advent-2025.ipynb) | 2025 | <a href="ipynb/Advent-2025.ipynb" title="Puzzle site with a coding puzzle for 12 days of Christmas, December 2025">Advent of Code 2025</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Advent-2025.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Advent-2025.ipynb) | 2025 | <a href="ipynb/Advent-2025.ipynb" title="Puzzle site with a coding puzzle for 12 days of Christmas, December 2025">Advent of Code 2025</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Advent-2025-AI.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Advent-2025-AI.ipynb) | 2025 | <a href="ipynb/Advent-2025-AI.ipynb" title="Using large language coding models to solve AoC puzzles">Advent of Code 2025: AI LLM Edition</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Advent-2025-AI.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Advent-2025-AI.ipynb) | 2025 | <a href="ipynb/Advent-2025-AI.ipynb" title="Using large language coding models to solve AoC puzzles">Advent of Code 2025: AI LLM Edition</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Advent-2025-AI.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Advent-2025-AI.ipynb) | 2025 | <a href="ipynb/Advent-2025-AI.ipynb" title="Using large language coding models to solve AoC puzzles">Advent of Code 2025: AI LLM Edition</a> |
|Open|Year|Large Language Models| |Open|Year|Large Language Models|
@@ -114,7 +113,7 @@ For each notebook you can hover on the title to see a description, or click the
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Stubborn.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Stubborn.ipynb) | 2024 | <a href="ipynb/Stubborn.ipynb" title="Any number ending in 5 has a square that also ends in 5. What other endings are like this?">Stubborn number endings</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Stubborn.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Stubborn.ipynb) | 2024 | <a href="ipynb/Stubborn.ipynb" title="Any number ending in 5 has a square that also ends in 5. What other endings are like this?">Stubborn number endings</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/SquareSum.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/SquareSum.ipynb) | 2020 | <a href="ipynb/SquareSum.ipynb" title="Place the numbers from 1 to n in a chain (or a circle) such that adjacent pairs sum to a perfect square">Square Sum Chain Puzzle</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/SquareSum.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/SquareSum.ipynb) | 2020 | <a href="ipynb/SquareSum.ipynb" title="Place the numbers from 1 to n in a chain (or a circle) such that adjacent pairs sum to a perfect square">Square Sum Chain Puzzle</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Cheryl.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Cheryl.ipynb) | 2020 | <a href="ipynb/Cheryl.ipynb" title="Solving the *Cheryl's Birthday* logic puzzle">When is Cheryl's Birthday?</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Cheryl.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Cheryl.ipynb) | 2020 | <a href="ipynb/Cheryl.ipynb" title="Solving the *Cheryl's Birthday* logic puzzle">When is Cheryl's Birthday?</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Cheryl-and-Eve.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Cheryl-and-Eve.ipynb) | 2015 | <a href="ipynb/Cheryl-and-Eve.ipynb" title="Inventing new puzzles in the Style of Cheryl's Birthday">When Cheryl Met Eve: A Birthday Story</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/Cheryl-and-Eve.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/Cheryl-and-Eve.ipynb) | 2015 | <a href="ipynb/Cheryl-and-Eve.ipynb" title="Inventing puzzles in the Style of Cheryl's Birthday">When Cheryl Met Eve: A Birthday Story</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/xkcd1313.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/xkcd1313.ipynb) | 2015 | <a href="ipynb/xkcd1313.ipynb" title="Find the smallest regular expression; inspired by Randall Munroe">xkcd 1313: Regex Golf</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/xkcd1313.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/xkcd1313.ipynb) | 2015 | <a href="ipynb/xkcd1313.ipynb" title="Find the smallest regular expression; inspired by Randall Munroe">xkcd 1313: Regex Golf</a> |
| [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/xkcd1313-part2.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/xkcd1313-part2.ipynb) | 2015 | <a href="ipynb/xkcd1313-part2.ipynb" title="Regex Golf: better, faster, funner (with Stefan Pochmann)">xkcd 1313: Regex Golf (Part 2: Infinite Problems)</a> | | [co](https://colab.research.google.com/github/norvig/pytudes/blob/main/ipynb/xkcd1313-part2.ipynb) [nb](https://nbviewer.jupyter.org/github/norvig/pytudes/blob/main/ipynb/xkcd1313-part2.ipynb) | 2015 | <a href="ipynb/xkcd1313-part2.ipynb" title="Regex Golf: better, faster, funner (with Stefan Pochmann)">xkcd 1313: Regex Golf (Part 2: Infinite Problems)</a> |
+1 -1
View File
@@ -61,7 +61,7 @@
"> 9 &times; 7 &times; 5 &times; 3 &times; 1 = 945.\n", "> 9 &times; 7 &times; 5 &times; 3 &times; 1 = 945.\n",
"\n", "\n",
"(It is always a relief when two methods give the same answer.)\n", "(It is always a relief when two methods give the same answer.)\n",
" \n", "\n",
"**Method 3: Write a program to enumerate the sets:** We'll represent the 1 &times; 3 rectangle as the tuple `(1, 3)` and the example set of rectangles as the set\n", "**Method 3: Write a program to enumerate the sets:** We'll represent the 1 &times; 3 rectangle as the tuple `(1, 3)` and the example set of rectangles as the set\n",
"\n", "\n",
" {(1, 3), (2, 4), (5, 7), (6, 8), (9, 10)}\n", " {(1, 3), (2, 4), (5, 7), (6, 8), (9, 10)}\n",
+7 -8
View File
@@ -487,7 +487,7 @@
"source": [ "source": [
"**Bo: Look at that!**\n", "**Bo: Look at that!**\n",
"\n", "\n",
"Ali: It turns out you can <a href=\"https://www.mathartfun.com/dSpecial.html\">buy</a> a pair of dice with just these numbers, and there are some nice [charts and tables on Wikipedia](https://en.wikipedia.org/wiki/Sicherman_dice) explaining it all. \n", "Ali: It turns out you can <a href=\"https://www.mathartfun.com/dSpecial.html\">buy</a> a pair of dice with just these numbers, and there are some nice [charts and tables on Wikipedia](https://en.wikipedia.org/wiki/Sicherman_dice) ing it all. \n",
"\n", "\n",
"![Sicherman dice from MathArtFun.com](http://www.mathartfun.com/shopsite_sc/store/html/SichermanDots.jpg)\n", "![Sicherman dice from MathArtFun.com](http://www.mathartfun.com/shopsite_sc/store/html/SichermanDots.jpg)\n",
"\n", "\n",
@@ -1317,7 +1317,7 @@
"\n", "\n",
"Ali: In general, what's the sum of the sides of a standard pair?\n", "Ali: In general, what's the sum of the sides of a standard pair?\n",
"\n", "\n",
"**Bo: Easy, that's *N* × (*N* + 1). [Gauss](http://betterexplained.com/articles/techniques-for-adding-the-numbers-1-to-100/) knew that when he was in elementary school!**\n", "**Bo: Easy, that's *N* × (*N* + 1). [Gauss](http://bettered.com/articles/techniques-for-adding-the-numbers-1-to-100/) knew that when he was in elementary school!**\n",
"\n", "\n",
"# Better Efficiency\n", "# Better Efficiency\n",
"\n", "\n",
@@ -1727,11 +1727,11 @@
"|3|0| | |\n", "|3|0| | |\n",
"|4 | 1 | [1, 2, 2, 3] | [1, 3, 3, 5]|\n", "|4 | 1 | [1, 2, 2, 3] | [1, 3, 3, 5]|\n",
"|5|0| | |\n", "|5|0| | |\n",
"|6 | 1 | [1, 2, 2, 3, 3, 4] | [1, 3, 4, 5, 6, 8]\n", "|6 | 1 | [1, 2, 2, 3, 3, 4] | [1, 3, 4, 5, 6, 8]|\n",
"|7 | 0 |\n", "|7 | 0 | | |\n",
"|8 | 3 | [1, 2, 2, 3, 3, 4, 4, 5] | [1, 3, 5, 5, 7, 7, 9, 11]|\n", "|8 | 3 | [1, 2, 2, 3, 3, 4, 4, 5] | [1, 3, 5, 5, 7, 7, 9, 11]|\n",
" ||| [1, 2, 3, 3, 4, 4, 5, 6] | [1, 2, 5, 5, 6, 6, 9, 10]|\n", "||| [1, 2, 3, 3, 4, 4, 5, 6] | [1, 2, 5, 5, 6, 6, 9, 10]|\n",
" ||| [1, 2, 2, 3, 5, 6, 6, 7] | [1, 3, 3, 5, 5, 7, 7, 9]|\n", "||| [1, 2, 2, 3, 5, 6, 6, 7] | [1, 3, 3, 5, 5, 7, 7, 9]|\n",
"| 9 |1 | [1, 2, 2, 3, 3, 3, 4, 4, 5] | [1, 4, 4, 7, 7, 7, 10, 10, 13]|\n", "| 9 |1 | [1, 2, 2, 3, 3, 3, 4, 4, 5] | [1, 4, 4, 7, 7, 7, 10, 10, 13]|\n",
"| 10 | 1 | [1, 2, 2, 3, 3, 4, 4, 5, 5, 6] | [1, 3, 5, 6, 7, 8, 9, 10, 12, 14]|\n", "| 10 | 1 | [1, 2, 2, 3, 3, 4, 4, 5, 5, 6] | [1, 3, 5, 6, 7, 8, 9, 10, 12, 14]|\n",
"| 11 |0|||\n", "| 11 |0|||\n",
@@ -1751,10 +1751,9 @@
"\n", "\n",
"- Do all composite *N* have solutions?\n", "- Do all composite *N* have solutions?\n",
"- Does any prime *N* have a solution?\n", "- Does any prime *N* have a solution?\n",
"- Do some *N* have more than the 3 solutions that 8 has?\n",
"- Does the fact that 8 has 3 solutions have anything to do with the fact that 8 is a perfect cube?\n", "- Does the fact that 8 has 3 solutions have anything to do with the fact that 8 is a perfect cube?\n",
"- What about the 7 solutions for 12? 12 has 6 factors; does that matter?\n", "- What about the 7 solutions for 12? 12 has 6 factors; does that matter?\n",
"- The 9 perfect squares, 4 and 9, have 1 solution each; is that true of all perfect squares?\n", "- The perfect squares 4 and 9 have 1 solution each; is that true of all perfect squares?\n",
"- Could we make this 10 times faster? 100 times?\n", "- Could we make this 10 times faster? 100 times?\n",
"- Could we handle greater values of *N* if we worked with [generating functions](https://en.wikipedia.org/wiki/Sicherman_dice)?\n", "- Could we handle greater values of *N* if we worked with [generating functions](https://en.wikipedia.org/wiki/Sicherman_dice)?\n",
"- What about Sicherman triples (3 nonstandard dice with the same distribution of sums as 3 standard dice)?\n", "- What about Sicherman triples (3 nonstandard dice with the same distribution of sums as 3 standard dice)?\n",
+6 -6
View File
@@ -75,7 +75,7 @@ notebooks = {
("Stubborn number endings", 2024, 'Stubborn.ipynb', 'Any number ending in 5 has a square that also ends in 5. What other endings are like this?'), ("Stubborn number endings", 2024, 'Stubborn.ipynb', 'Any number ending in 5 has a square that also ends in 5. What other endings are like this?'),
('Square Sum Chain Puzzle', 2020, 'SquareSum.ipynb', 'Place the numbers from 1 to n in a chain (or a circle) such that adjacent pairs sum to a perfect square'), ('Square Sum Chain Puzzle', 2020, 'SquareSum.ipynb', 'Place the numbers from 1 to n in a chain (or a circle) such that adjacent pairs sum to a perfect square'),
("When is Cheryl's Birthday?", 2020, 'Cheryl.ipynb', "Solving the *Cheryl's Birthday* logic puzzle"), ("When is Cheryl's Birthday?", 2020, 'Cheryl.ipynb', "Solving the *Cheryl's Birthday* logic puzzle"),
('When Cheryl Met Eve: A Birthday Story', 2015, 'Cheryl-and-Eve.ipynb', "Inventing new puzzles in the Style of Cheryl's Birthday"), ('When Cheryl Met Eve: A Birthday Story', 2015, 'Cheryl-and-Eve.ipynb', "Inventing puzzles in the Style of Cheryl's Birthday"),
('xkcd 1313: Regex Golf', 2015, 'xkcd1313.ipynb', 'Find the smallest regular expression; inspired by Randall Munroe'), ('xkcd 1313: Regex Golf', 2015, 'xkcd1313.ipynb', 'Find the smallest regular expression; inspired by Randall Munroe'),
('xkcd 1313: Regex Golf (Part 2: Infinite Problems)', 2015, 'xkcd1313-part2.ipynb', 'Regex Golf: better, faster, funner (with Stefan Pochmann)')], ('xkcd 1313: Regex Golf (Part 2: Infinite Problems)', 2015, 'xkcd1313-part2.ipynb', 'Regex Golf: better, faster, funner (with Stefan Pochmann)')],
@@ -194,13 +194,13 @@ def format_notebooks() -> str:
find_newest(notebooks) find_newest(notebooks)
return '\n'.join(format_category(name) for name in notebooks) return '\n'.join(format_category(name) for name in notebooks)
def find_newest(notebooks, label='New', year=new_year) -> None: def find_newest(notebooks, New='New', year=new_year) -> None:
"""Mutate `notebooks['New']` to have a collection of newest notebooks.""" """Mutate `notebooks[New]` to have a collection of newest notebooks, from `new_year` or later."""
for category in notebooks: for category in notebooks:
for line in notebooks[category]: for line in notebooks[category]:
if line[1] >= year: if line[1] >= year and line not in notebooks[New]:
notebooks[label].append(line) notebooks[New].append(line)
notebooks[label].sort(key=lambda line: (-line[1], line[0])) notebooks[New].sort(key=lambda line: (-line[1], line[0]))
def format_category(category) -> str: def format_category(category) -> str:
"""Make a table of multiple jupyter/ipython notebooks, under a header.""" """Make a table of multiple jupyter/ipython notebooks, under a header."""