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 / just-a-scene.pbrt
Last active February 20, 2016 23:09
PBRT Scene
Film "image"
"integer xresolution" [1280] "integer yresolution" [1024]
Sampler "lowdiscrepancy" "integer pixelsamples" [8]
PixelFilter "box"
LookAt 10 4 10 0 0.5 0 0 1 0
Camera "perspective" "float fov" [20]
@Chris--B
Chris--B / list.rs
Last active August 29, 2015 14:01
CS Connect Question of the Week: nth to last element of a singly linked list
#[deriving(Show)]
enum List<T> {
Node(T, ~List<T>),
Nil,
}
impl<T> List<T> {
fn len(&self) -> uint {
match *self {
Node(_, ref tail) => tail.len() + 1,
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; }
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
;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 }
int factorial(int n)
{
if(n == 0) {
return 1;
} else {
return n * factorial (n - 1);
}
}
public int readFile(String filename)
{
try
{
Scanner scan = new Scanner(new File(filename));
int i = 0
while(scan.hasNext())
{
strings[i] = scan.nextLine();
++i;
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
#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
@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;