Skip to content

Instantly share code, notes, and snippets.

View huffman's full-sized avatar

Ryan Huffman huffman

View GitHub Profile
@huffman
huffman / c.c
Created September 8, 2012 05:08
// Compiled with -O3
// cat C-large-practice.in 0.00s user 0.00s system 81% cpu 0.003 total
// ./a.out 4.18s user 0.13s system 99% cpu 4.318 total
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NOT_FOUND 0xFFFFFFFF
#define MAX_PRISONERS 10000
#!/usr/bin/env python
# -*- coding: latin-1 -*-
# Euler published the remarkable quadratic formula:
#
# n² + n + 41
#
# It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40(40 + 1) + 41 is divisible by 41, and certainly when n = 41, 41² + 41 + 41 is clearly divisible by 41.
#
# Using computers, the incredible formula n² − 79n + 1601 was discovered, which produces 80 primes for the consecutive values n = 0 to 79. The product of the coefficients, −79 and 1601, is −126479.
from math import factorial
digits = "0123456789"
target = 1000000
def lex(perm, values):
vlen = len(values)
for i in xrange(vlen):
num_perms = factorial(vlen - i)
if perm >= num_perms:
day = 1
year = 1900
mons = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
fom_sundays = 0
def is_leap_year(year):
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
while year < 2001:
@huffman
huffman / elixir.rb
Created March 2, 2012 03:50
Elixir Homebrew recipe
# Install this recipe with:
# brew install --HEAD https://raw.github.com/gist/1955470/c58bda92f07147afff64a86d0c2d8ef65adb9cd6/elixir.rb
require 'formula'
class Elixir < Formula
homepage 'http://elixir-lang.org/'
head 'https://github.com/elixir-lang/elixir.git'
depends_on 'erlang'
--- file_templates.vba 2011-02-24 22:53:45.000000000 -0800
+++ file_templates_updated.vba 2011-02-24 22:54:15.000000000 -0800
@@ -165,6 +165,7 @@
\ '$LBASENAME$': tolower(expand('%:t:r')),
\ '$YEAR$': strftime("%Y"),
\ '$DATE$': strftime('%d/%m/%Y'),
+ \ '$FULLDATE$': strftime('%d %b %Y'),
\ }
let [lnum, cnum] = searchpos(s:VarTagMatch)