Skip to content

Instantly share code, notes, and snippets.

View logalleon's full-sized avatar
🍄

Logan S. logalleon

🍄
View GitHub Profile
enum DwarfStatus {
NO_JOB,
NO_DESTINATION,
SLEEPING,
ACTIVE
}
@logalleon
logalleon / 14.cpp
Created July 14, 2015 02:48
Project Euler 14
#include <iostream>
#include <algorithm>
using namespace::std;
int chainLength(unsigned long long x){
int len = 1;
while (x > 1){
if (x % 2) x = 3*x + 1;
else x /= 2;
@logalleon
logalleon / 8.cpp
Last active August 29, 2015 14:24
Project Euler 8
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace::std;
// Finds the maximum product of n sequential digits in an s-sized series.
long long findSeriesProduct(int a[], int s, int n, int i){
// Base case
if (n + i > s) return 0;
@logalleon
logalleon / 28.cpp
Last active August 29, 2015 14:24
Project Euler 28
#include <iostream>
using namespace::std;
// Calculates the sum of the diagonals of number spiral size s x s.
int spiralDiagonalSum(int s) {
// The size of the spiral
int start = s*s;
// Starting array offset
int offset = s-1;
@logalleon
logalleon / json-to-csv.js
Last active August 29, 2015 14:24
JSON to CSV
/*
* Logan H. Sobczak 6/24/15
* Converts arbitrary JSON to CSV
*
* node json-to-csv.js [file1.json, file2.json, ... ]
* outputs to ./csv/file1.csv, ./csv/file2.csv . . .
*/
var fs = require('fs'),
files = process.argv.slice(2);