This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Diagonal array generator. | |
| Start at top right corner going diagonally up | |
| and end in the bottom left corner. | |
| Bruce Wernick | |
| 13 August 2025 | |
| """ | |
| def diag(arr): | |
| nr = len(arr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Get all the factors of a number. | |
| Bruce Wernick | |
| 13 August 2025 | |
| """ | |
| import math | |
| def get_factors(n): | |
| arr = set() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Closure to create an interpolator function. | |
| Bruce Wernick | |
| 13 August 2025 | |
| """ | |
| def lagrange(xp, yp): | |
| n = len(xp) | |
| def inner(x): | |
| value = 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Root finder as a closure. Has benefits over the class | |
| approach because you are not carrying around self. | |
| This demo is not really for the root finder. It's mainly | |
| to demonstrate the use of closures in solving this kind | |
| of problem. So, I don't implement all the methods. | |
| Also, the methods that are implemented don't have all | |
| the safeties. Things like checking for zero slope or | |
| max iteration limit reached. | |
| Bruce Wernick |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Traditional Newton root finding method | |
| and Alternative using decorators... | |
| Author: Bruce Wernick | |
| Date: 13 August 2025 | |
| """ | |
| def newt(f, x, **kwargs): | |
| maxits = kwargs.get("maxits", 48) | |
| tol = kwargs.get("tol", 1e-6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tkinter as tk | |
| from tkinter import ttk | |
| class App(tk.Tk): | |
| def __init__(self): | |
| super().__init__() | |
| self.geometry("600x400+500+10") | |
| self.title("App") | |
| self.style = ttk.Style() | |
| self.style.theme_use("clam") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tkinter as tk | |
| from tkinter import ttk | |
| root = tk.Tk() | |
| root.title("App") | |
| root.geometry("400x400+600+10") | |
| root.mainloop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 2D array traversal | |
| # These are not really for production use, | |
| # they are more to demonstrate how to traverse 2-D arrays. | |
| # Bruce Wernick | |
| # 31 January 2022 | |
| from collections import deque | |
| import itertools | |
| from random import shuffle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hybrid_150.json | |
| hybrid_300.json |