Skip to content

Instantly share code, notes, and snippets.

@zacharysyoung
zacharysyoung / permute.py
Last active June 30, 2019 04:57
Still playing around with this silly recursive function for permutating a positional notation
def permute(n, chars='01', limit=128, start=0):
appended = 0
counter = 0
def f(s, a):
nonlocal appended
nonlocal counter
if appended == limit:
return a
if len(s) == n:
@zacharysyoung
zacharysyoung / astro_circf.py
Last active June 25, 2019 20:01
Prints a circumference of astronomical sizes in miles-feet-inches
# Inspired by:
# 'How many digits of pi do we really need?'
# (https://www.jpl.nasa.gov/edu/news/2016/3/16/how-many-decimals-of-pi-do-we-really-need/)
#
# I wanted to see for myself that the difference between 15 digits and 16
# digits amounted to only half of an inch at the scale of Voyager 1's
# distance of ~12.5 billion miles
from decimal import Decimal, getcontext
@zacharysyoung
zacharysyoung / a_main.go
Last active July 27, 2020 21:35
'The Go Programming Language', Exercise 1.4
// Exercise 1.4 from 'The Go Programming Language', by A Donovan and
// B Kernigham
//
// Zach Young
// 27 May, 2019
//
//Dup2 prints the count and text of lines that appear more than once
//in the input. It reads from stdin or from a list of named files.
package main
@zacharysyoung
zacharysyoung / make_test_gmails.go
Last active May 27, 2019 08:47
Permutate punctuation (dots) for test email name
package main
/*
Got the idea from https://learn.lytics.com/understanding/product-docs/lytics-javascript-tag/testing-and-verification#testing-audiences
Given an input of "test", makes:
t.e.s.t.@gmail.com
t.e.s.t@gmail.com
t.e.st.@gmail.com
@zacharysyoung
zacharysyoung / make_test_gmails.py
Last active May 24, 2019 17:30
Permutate punctuation for test GMails
#!/usr/bin/env python
import sys
"""
Got the idea from https://learn.lytics.com/understanding/product-docs/lytics-javascript-tag/testing-and-verification#testing-audiences
Given an input of "test", makes:
t.e.s.t.@gmail.com
t.e.s.t@gmail.com
t.e.st.@gmail.com