Skip to content

Instantly share code, notes, and snippets.

View Chris--B's full-sized avatar

Chris Chris--B

  • Boulder, CO
View GitHub Profile
@Chris--B
Chris--B / P2.java
Created September 8, 2012 23:20 — forked from wowmindy/gist:3670021
import java.text.DecimalFormat;
import java.util.Scanner;
/* P2
* Mindy Mach
* w/ changes by Chris
*/
public class P2 {
@Chris--B
Chris--B / binarytree.java
Created October 1, 2012 03:20
idontknowwhatimdoing
public void copyn(BinaryTree other, int depth)
{
copyn_r(other.root, depth);
}
private void copyn_r(node n, int depth)
{
if(n == null)
return;
else
@Chris--B
Chris--B / P5.java
Created October 22, 2012 00:20
CSU P5
package chris;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include "eratos.h"
#define PRIME_LIMIT (uint64_t)1e5
#define ALLOWED_CHAINS (uint64_t)30e7
#define ARRAY_ELEMS (uint64_t)40
from functools import reduce
from operator import add
#Doesn't handle whitespace padding well
def countWords(s):
return len(s.split(' '))
def stopLooping():
global looping
looping = False
public int readFile(String filename)
{
try
{
Scanner scan = new Scanner(new File(filename));
int i = 0
while(scan.hasNext())
{
strings[i] = scan.nextLine();
++i;
int factorial(int n)
{
if(n == 0) {
return 1;
} else {
return n * factorial (n - 1);
}
}
;clang version 3.2 (tags/RELEASE_32/final)
;Target: x86_64-unknown-linux-gnu
;Thread model: posix
; ModuleID = 'degrad.cpp'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%class.Radians = type { float }
def next(life, power, counters):
for _ in range(1):
life += 2 * power
counters += 2 * power
power = life + counters
return life, power, counters
def power_at(turn, life, power, counters):
return 5 ** turn * (life + power + 4 * counters) * 2 // 7
int Board::countLivingNeighbors(const Cell& cell) const {
auto living = 0;
if (isAlive(Cell(cell.x - 1, cell.y))) { ++living; }
if (isAlive(Cell(cell.x - 1, cell.y - 1))) { ++living; }
if (isAlive(Cell(cell.x - 1, cell.y + 1))) { ++living; }
if (isAlive(Cell(cell.x, cell.y - 1))) { ++living; }
if (isAlive(Cell(cell.x, cell.y + 1))) { ++living; }
if (isAlive(Cell(cell.x + 1, cell.y))) { ++living; }
if (isAlive(Cell(cell.x + 1, cell.y - 1))) { ++living; }