This file contains 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
def periodic(L: list): | |
"""Return an infinite periodic continued fraction representation.""" | |
# Create a copy of the list and append it to itself. | |
# This creates an "infinite" list of the form [a0, ..., an, [a0, ..., an, [a0, ..., an, ...]]] | |
# The list is not actually infinite, it only has length n+1! It has infinite depth and finite length 🤯 | |
S = list(L) | |
S.append(S) | |
return S | |
# EXAMPLES: |
This file contains 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 sys | |
import termios | |
import time | |
import tty | |
import random | |
def read_char(): | |
fd = sys.stdin.fileno() | |
old_settings = termios.tcgetattr(fd) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
using Base.Iterators | |
RIGHT = (0, 1) | |
DOWN = (1, 0) | |
LEFT = (0, -1) | |
UP = (-1, 0) | |
function involute(n::Int)::Matrix{Int} | |
directions = cycle((RIGHT, DOWN, LEFT, UP)) | |
repeats = pushfirst!(collect(flatten(zip(n-1:-1:1, n-1:-1:1))), n-1) |
This file contains 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
using Javis | |
video = Video(500, 500) | |
N = 12 | |
frames = 4(N+1) | |
Background(1:frames, (args...) -> background("grey70")) | |
# Draw crosshairs | |
Object(@JShape begin |
This file contains 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
using Animations | |
using ColorSchemes | |
using Javis | |
N = 6 # number of circles | |
radius = 20 # Radius of each circles | |
speed = 5 # degrees per frame | |
colors = ColorSchemes.rainbow1 | |
video = Video(500, 500) |
This file contains 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
using ColorSchemes | |
using Javis | |
N = 6 # Number of dots | |
radius = 20 # Radius of each dot | |
colors = ColorSchemes.rainbow1 # Color palette | |
speed = 10 # Degrees per frame | |
function draw_circle(frame, i, radius, speed) | |
# Angle of the direction vector for the dot |
This file contains 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
using Javis | |
using ColorSchemes | |
# Set the color scheme | |
# More options: | |
# https://juliagraphics.github.io/ColorSchemes.jl/stable/catalogue/ | |
colors = ColorSchemes.cool | |
function circ(radius, color="white") | |
sethue(color) # Set the color of the circle |
This file contains 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 LinearAlgebra as LinAlg | |
import SparseArrays | |
import Graphs | |
import GraphRecipes: graphplot | |
import Plots: savefig | |
import WAV | |
function normalized_laplacian_matrix(g::Graphs.SimpleGraph) |
This file contains 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 LinearAlgebra as LinAlg | |
import SparseArrays | |
import Graphs | |
import WAV | |
function normalized_laplacian_matrix(g::Graphs.SimpleGraph) | |
A = Graphs.CombinatorialAdjacency(Graphs.adjacency_matrix(g).+ 0.0) | |
 = Graphs.NormalizedAdjacency(A) |
NewerOlder