Skip to content

Instantly share code, notes, and snippets.

@zrbecker
zrbecker / euler9.c
Created April 22, 2011 09:05
Euler 9
#include <stdio.h>
#define MAX 1000
int main() {
int a, b, c;
a = 0;
b = 1;
c = MAX - a - b;
@zrbecker
zrbecker / euler10.c
Created April 22, 2011 09:20
Euler 10
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef unsigned long ul;
ul *maxprimeslist(ul max, int *found) {
int cprimes = 10;
ul *primes = (ul *)malloc(cprimes * sizeof(ul));
int nprimes = 0;
@zrbecker
zrbecker / makefile
Created April 22, 2011 17:17
Go makefile
GOC=6g
GOCFLAGS=
GOLINK=6l
GOLINKFLAGS=
SOURCES=helloworld.go
DEPS=
EXECUTABLE=helloworld
OBJECTS=$(SOURCES:.go=.6)
@zrbecker
zrbecker / primes.go
Created April 22, 2011 18:35
Primes
package main
import (
"os"
"fmt"
"math"
"strconv"
)
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
int nthprime(int n) {
int *primes = (int *)calloc(n, sizeof(int));
int i, count = 0;
@zrbecker
zrbecker / ipe.rb
Created May 7, 2011 13:14
Ipe Formula for Mac Homebrew
require 'formula'
class Ipe < Formula
url 'http://downloads.sourceforge.net/project/ipe7/ipe/ipe-7.0.14-src.tar.gz'
homepage 'http://ipe7.sourceforge.net/'
md5 '13b1790813304ac888402d9c6c40a6ec'
depends_on "pkg-config"
depends_on "lua"
depends_on "qt"
test -z "/Users/zrbecker/local/homebrew/Cellar/irssi/0.8.15/lib/irssi/modules" || ../../build-aux/install-sh -c -d "/Users/zrbecker/local/homebrew/Cellar/irssi/0.8.15/lib/irssi/modules"
Appending installation info to /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level/perllocal.pod
mkdir /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level: Permission denied at /System/Library/Perl/5.10.0/ExtUtils/Command.pm line 259
make[5]: [doc_site_install] Error 13 (ignored)
/bin/sh: /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level/perllocal.pod: No such file or directory
make[5]: [doc_site_install] Error 1 (ignored)
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/Library/Perl/5.10.0/darwin-thread-multi-2level'
Do not have write permissions on '/Library/Perl/5.10.0/darwin-thread-multi-2level'
#include <stdio.h>
int main()
{
int n = 0;
while (n + 1 > n)
++n;
printf("Done!\n");
return 0;
import sys
def isprime(p, plist):
max = p ** 0.5
for i in range(0, len(plist)):
if max < plist[i]:
break
if p % plist[i] == 0:
return False
return True
@zrbecker
zrbecker / attack_probable_move_strategy.py
Created June 27, 2011 05:03
Attack Probable Move Strategy
def attack_probable_move_strategy(history):
"""Chooses best response to opponents most probable response based on
last 100 moves."""
probable_move = [0, 0, 0, 0, 0, 0, 0]
# Calculates response to last move based on previous 100 moves
last_l = -1
for l, r in history[-100:]:
if last_l == history[-1][0]:
probable_move[r] += 1