Skip to content

Instantly share code, notes, and snippets.

@jwnelson
jwnelson / primes_in_range.py
Last active July 27, 2016 02:51
Script that finds the number of primes produced by the function x^2 - 2999x + 2248541 evaluated over a range of integers passed in as args. Produces 80 primes between 1460 and 1539 (inclusive). Inspired by this tweet from @AlgebraFact: https://twitter.com/AlgebraFact/status/757674572254674944
#!/usr/bin/python
"""
Finds the number of primes produced by the function x^2 - 2999x + 2248541
evaluated over a range of integers passed in as args. Produces 80 primes
between 1460 and 1539 (inclusive). Inspired by this tweet from @AlgebraFact:
https://twitter.com/AlgebraFact/status/757674572254674944
Usage:
./primes_in_range.py <lower bound> <upper bound>
"""
@jwnelson
jwnelson / raven_extract.py
Created April 11, 2016 00:41
Extracts time-series acceleration from a csv of Raven amateur rocket altimeter data and plots it.
import matplotlib.pyplot as plt
import numpy as np
import csv
def extract_raven_accel(ravenfile, start_time = 0.0, end_time = 60.0, trim_head = 0, print_interval = 1000000):
"""
Use this to pull acceleration data from a raven raw export file.
Returns an Nx2 array of times (col 1) and accel values (col 2) in ft/s/s
Assumes col 0 of the raven csv data is time, and col 15 is acceleration.
"""
@jwnelson
jwnelson / nagaram.py
Last active August 29, 2015 14:23
Searches for anagrams of words in a dictionary with at least four letters and at least as many anagrams as letters.
#!/usr/bin/python
import math
import sys
import argparse
import time
# Nagaram.py
#
# OVERVIEW
# Searches a dictionary of common English words for anagrams with at least