Skip to content

Instantly share code, notes, and snippets.

View calebrob6's full-sized avatar

Caleb Robinson calebrob6

View GitHub Profile
import itertools,operator
ops=[operator.add,operator.sub,operator.mul,operator.div]
opCombs = list(itertools.product(ops,ops,ops))
def customReduce(operators,nums):
total = nums[0]
for i in range(len(operators)):
if operators[i] == operator.div and nums[i+1]==0:
return 1000001
7 2 5 1
8 15 38 3
0 0 0 0
f=open("6219.txt","r")
line=f.readline().strip()
while line!="0 0.00":
line = line.split(" ")
n = int(line[0])
money = int(float(line[1])*100)
vals = []
for i in range(n):
import java.util.ArrayList;
public class GrowArray {
public static void main(String[] args) {
ArrayList<Integer> test = new ArrayList<Integer>();
long maxTime = 0;
for(int i=0;i<100000000;i++){
@calebrob6
calebrob6 / problem4691.py
Created October 25, 2013 00:00
3 5 0 2 5 0 6 1 2 0 3 7 0 0 2 8 0
f=open("problem4691.txt","r")
dims = list(map(int,f.readline().strip().split(" ")))
board = []
q = []
for i in range(dims[0]):
board.append(list(map(int,f.readline().strip().split(" "))))
#print(board)
@calebrob6
calebrob6 / triangles.py
Created November 13, 2013 18:25
Python script that renders a triangle by testing to see if a point is inside the triangle.
import sys,os,math
def distance(p1,p2):
return abs(math.sqrt( (p2[0]-p1[0])**2 + (p2[1]-p1[1])**2 ))
def getAngle(s1,s2,s3):
try:
return math.acos( round((s1**2 + s2**2 - s3**2)/(2*s1*s2),3) ) * (180 / math.pi)
except:
return 2
@calebrob6
calebrob6 / dowork.c
Last active August 29, 2015 13:59
Does stuff
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <malloc.h>
int main(int argc, char* argv[])
{
char *name = "enwik8.zip";
FILE *file;
@calebrob6
calebrob6 / cellularAutomata.c
Created August 25, 2014 20:03
Automata in C
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <malloc.h>
int main(int argc, char* argv[])
{
/*
char *name = "test.txt";
@calebrob6
calebrob6 / addPageNumbers.py
Created October 2, 2014 18:18
This script adds page numbers (skipping the title page) to a PDF file (Google drive presentation PDF).
from pyPdf import PdfFileWriter, PdfFileReader
import StringIO
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
existing_pdf = PdfFileReader(file("test.pdf", "rb"))
output = PdfFileWriter()
numPages = existing_pdf.getNumPages()
size = existing_pdf.getPage(0)['/MediaBox']
@calebrob6
calebrob6 / hashingSHA256.cpp
Created October 3, 2014 06:57
SHA256 Hashing Challenge Program
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <openssl/sha.h>
static const char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int main(){