This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Order Statistics | |
# Ameer Ayoub <ameer.ayoub@gmail.com> | |
import random, copy | |
# From quicksort | |
# Nonrandomized Pivot | |
def partition(l, p, q, pivot=None): | |
r = copy.copy(l) | |
if pivot: | |
r[pivot], r[p] = r[p], r[pivot] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fractions import gcd | |
def euler39optimized(): | |
sum_count = [0] * 1001 | |
y = 2 | |
while y**2 <= 500: | |
for z in [x for x in range(y) if gcd(y, x) == 1]: | |
a = y**2 - z**2 | |
b = 2*y*z | |
c = y**2 + z**2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# increment_version_num.py | |
# Utility to incremement version number in drupal info files | |
# Ameer Ayoub <ameer.ayoub@gmail.com> | |
import re, sys, os | |
major_v = 0 | |
minor_v = 0 | |
def inc_dv_num(s, minor = True): | |
global major_v, minor_v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Fibonacci Calculation using Matrices | |
* Ameer Ayoub <ameer.ayoub@gmail.com> | |
* Jun 13, 2011 | |
*/ | |
#include <iostream> | |
#include <math.h> | |
using namespace std; | |
const int fib_matrix_size = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These little programs read a spelt (EDIT: it is not "spoken") number from the | |
standard input and write the corresponding number to the standard output. Weigh | |
just 243 bytes and 227 bytes of C. (EDIT: was originally 256 and 240 bytes.) | |
The longer version handles numbers up to 999,999,999,999,999, that is, just | |
shy of 1,000 trillions. The shorter version handles numbers up to 19,999,999, | |
or 999,999,999 if your "int" is 64 bits long. The input should be correct, | |
although it will handle "a" and "and" correctly and ignore some invalid | |
words. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using StructureMap; | |
namespace ConsoleApplication1 | |
{ | |
class Program { | |
private static void Main(string[] args) { | |
IContainer container = ConfigureDependencies(); | |
IAppEngine appEngine = container.GetInstance<IAppEngine>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BunchO Sorting Algorithms | |
# Ameer Ayoub <ameer.ayoub@gmail.com> | |
# Last Modified 12/2/2010 | |
import random | |
# | |
# Insertion Sort | |
# | |
def insertion_sort(l): | |
"""Given an input list, returns a sorted permutation of the list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery | |
set nocompatible | |
set autoindent | |
set tabstop=2 | |
set showmatch | |
set vb t_vb= | |
set ruler | |
set nohls | |
set incsearch | |
syntax on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Google Weather API Conditions. Compiled by Dennis Delimarsky, http://dennisdel.com/content/conditions.xml--> | |
<!--Tweaked by Brian Zerangue, February 1, 2011--> | |
<conditions> | |
<type handle="partly-sunny">Partly Sunny</type> | |
<type handle="scattered-thunderstorms">Scattered Thunderstorms</type> | |
<type handle="showers">Showers</type> | |
<type handle="scattered-showers">Scattered Showers</type> | |
<type handle="rain-and-snow">Rain and Snow</type> | |
<type handle="overcast">Overcast</type> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Boyer Moore String Search implementation in Python | |
# Ameer Ayoub <ameer.ayoub@gmail.com> | |
# Generate the Bad Character Skip List | |
def generateBadCharShift(term): | |
skipList = {} | |
for i in range(0, len(term)-1): | |
skipList[term[i]] = len(term)-i-1 | |
return skipList |
OlderNewer