[ create a new paste ] login | about

gre

Name:
Email:
Site/Blog: http://math.uncc.edu/~genos/
Location:
Default language: Python
Favorite languages: Python, Haskell, Scheme, C, C++
About:

Saved pastes by gre:

Python, pasted on Sep 14:
1
2
3
4
5
from itertools import count


def factors(n):
    while (n % 2 == 0):
...
view (48 lines, 2 lines of output)
Python, pasted on Sep 14:
1
2
3
4
5
def factors(n):
    if (n & 1 == 0):
        fs = [2]
        fs.extend(factors(n // 2))
    else:
...
view (41 lines, 2 lines of output)
Python, pasted on Jun 11:
1
2
3
4
5
#!/usr/bin/env python
"""shamir_threshold_scheme.py

Shamir's (k, n) threshold scheme. See "The Handbook of Applied Cryptography" or
Shamir's 1979 paper, "How to Share a Secret."
...
view (76 lines, 22 lines of output)
Python, pasted on Mar 6:
1
2
3
4
5
#################
# c2.pyx
# compile this with the help of setup.py (below), via:
# python setup.py build_ext --inplace
#################
...
view (73 lines)
Python, pasted on Feb 25:
1
2
3
4
5
#!/usr/bin/env python


def _drop_mults(xs):
    for i in xrange(0, len(xs), xs[0]):
...
view (62 lines, 8 lines of output)
Python, pasted on Feb 18:
1
2
3
4
5
#!/usr/bin/env python

############################
#     Behind the Scenes    #
############################
...
view (109 lines)
Python, pasted on Feb 9:
1
2
3
4
5
#!/usr/bin/env python

"""random_ge_one.py

Add up uniformly distributed random numbers between zero and one, counting how
...
view (43 lines, 1 line of output)
Python, pasted on Feb 4:
1
2
3
4
5
#!/usr/bin/env python


def column1(exc):
    c = 0
...
view (48 lines, 17 lines of output)
Python, pasted on Feb 4:
1
2
3
4
#!/usr/bin/env python

### prime & ilog2 helpers
import itertools
...
view (140 lines, 4 lines of output)
Python, pasted on Feb 4:
1
2
3
4
#!/usr/bin/env python

import itertools
from math import log
...
view (131 lines, 4 lines of output)
Python, pasted on Jan 28:
1
2
3
4
5
#!/usr/bin/env python


def pop1(n):
# Naive; first changes n to binary, then adds up bits one by one
...
view (78 lines)
Python, pasted on Jan 2:
1
2
3
4
5
#!/usr/bin/env python


def make_heap():
    return []
...
view (123 lines, 1 line of output)
Python, pasted on Dec 31:
1
2
3
4
5
def make_heap():
    return []

def find_min(h):
    return h[0]
...
view (112 lines, 1 line of output)
Python, pasted on Dec 31:
1
2
3
4
5
#!/usr/bin/env python

"""dijkstraMaster.py

A submission to Programming Praxis for Dijkstra's Algorithm. Uses a min
...
view (129 lines, 1 line of output)
Python, pasted on Dec 28:
1
2
3
4
5
#!/usr/bin/env python

import random
from cookbook import primes
# Sieve of Eratosthenes based primes < n, speedy and space efficient
...
view (69 lines)
Python, pasted on Dec 27:
1
2
3
4
5
#!/usr/bin/env python
"""
dijkstra2.py

A slightly faster implementation of Dijkstra's Algorithm, using a linear search
...
view (59 lines, 1 line of output)
Python, pasted on Dec 27:
1
2
3
4
5
#!/usr/bin/env python
"""
My submission to Programming Praxis for "Tracking Santa":
http://programmingpraxis.com/2010/12/24/tracking-santa/
To run, save the data.js file in the same directory, delete "var locations = "
...
view (50 lines)
Python, pasted on Dec 26:
1
2
3
4
5
#!/usr/bin/env python
"""
dijkstra.py

A conceptually simpler but less efficient implementation of Dijkstra's
...
view (75 lines, 1 line of output)
Python, pasted on Dec 21:
1
2
3
4
5
"""
interval.py

My submission for Programming Praxis's "Interval Arithmetic" exercise; see
http://programmingpraxis.com/2010/12/21/interval-arithmetic/
...
view (77 lines)
C, pasted on Oct 15:
1
2
3
4
#include <stdio.h>

struct node {
    float val;
...
view (39 lines, 11 lines of output)
Python, pasted on Jul 24:
1
2
3
4
5
#!/usr/bin/env python
"""
Determines all the happy numbers less than upper bound of 100.

GRE, 7/24/10
...
view (78 lines, 19 lines of output)