Skip to content

Instantly share code, notes, and snippets.

@thomie
thomie / unique_permutations.pl
Created June 4, 2011 15:37
Unique permutations
# Generate all unique permutations of an array
# with possibly duplicate elements (multiset).
# unique_permutations(('A', 'B', 'B')) -> ABB BAB BBA
sub unique_permutations
{
my @results;
my (@list) = @_;
if ($#list == -1) {
return [()];
@thomie
thomie / self-replication.py
Created June 2, 2011 17:03
Self replicating code
x = 'print "x = " + chr(39) + x + chr(39) + "; exec(x)"'; exec(x)
@thomie
thomie / rename-greens-functions.sh
Created August 18, 2010 09:13
Rename Green's functions
#!/bin/sh
FILES='
Makefile.am
*.hpp
*.cpp
*.py
test/Makefile.am
test/*.cpp
test/*.py