Skip to content

Instantly share code, notes, and snippets.

View altaurog's full-sized avatar

Aryeh Leib Taurog altaurog

View GitHub Profile
@altaurog
altaurog / numbersets.py
Last active August 29, 2015 14:27
Find set S of 7 numbers such that the set of all sums s1, s1 + s2, s1 + s2 + s3 for s1, s2, and s3 in S contains the set of positive integers [1, 70]
import multiprocessing
import sys
def rsetgen(count, floor, ceiling):
"""
Recursively generate all possible sets of
count unique numbers between floor and ceiling
"""
if 1 == count:
for i in xrange(floor, ceiling):
@altaurog
altaurog / pnid.py
Created August 12, 2015 20:07
Get PID of n'th parent (linux only)
import os
"""
Get PID of n'th parent
This works in linux only
"""
def pnid(n=1, pid=os.getpid()):
for i in range(n):
try:
procfile = open("/proc/%s/status" % pid)