This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum DwarfStatus { | |
NO_JOB, | |
NO_DESTINATION, | |
SLEEPING, | |
ACTIVE | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fn (status: DwarfStatus): void { | |
switch (status) { | |
case DwarfStatus.ACTIVE: | |
/* ... do things */ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fn (status: DwarfStatus): void { | |
switch (status) { | |
case DwarfStatus.ACTIVE: | |
break; | |
case DwarfStatus.NO_DESTINATION: | |
break; | |
case DwarfStatus.NO_JOB: | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fn (status: DwarfStatus): void { | |
switch (status) { | |
case DwarfStatus.ACTIVE: | |
break; | |
case DwarfStatus.NO_DESTINATION: | |
break; | |
case DwarfStatus.NO_JOB: | |
break; | |
default: | |
_never(status); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const renderMap: RenderMap = { | |
[DwarfStatus.NO_DESTINATION]: { char: 'ø' } | |
} | |
renderMap[DwarfStatus.NO_JOB] = { char: 'n' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DwarfStatus; | |
(function (DwarfStatus) { | |
DwarfStatus[DwarfStatus["NO_JOB"] = 0] = "NO_JOB"; | |
DwarfStatus[DwarfStatus["NO_DESTINATION"] = 1] = "NO_DESTINATION"; | |
DwarfStatus[DwarfStatus["SLEEPING"] = 2] = "SLEEPING"; | |
DwarfStatus[DwarfStatus["ACTIVE"] = 3] = "ACTIVE"; | |
})(DwarfStatus || (DwarfStatus = {})); |
OlderNewer