Skip to content

Instantly share code, notes, and snippets.

View CharlotteGore's full-sized avatar

Charlotte Gore CharlotteGore

View GitHub Profile
const permutations = arr => {
let perms = [];
for (let i = 0; i < arr.length; i++) {
let rest = permutations(arr.slice(0, i).concat(arr.slice(i + 1)));
if(!rest.length) {
perms.push([arr[i]])
continue;
}
@CharlotteGore
CharlotteGore / day6aoc2018.js
Created December 6, 2019 08:28
Day 6 of AOC 2018
var run = src => {
const input = src.split(/\n/).map(m => m.split(/\)/));
const node = (id) => {
const o = {
id,
parent: null,
children: []
}
@CharlotteGore
CharlotteGore / intcode.js
Last active December 6, 2019 11:21
day4 aoc2019
var run = input => {
const program = new Int32Array(`3,225,1,225,6,6,1100,1,238,225,104,0,101,14,135,224,101,-69,224,224,4,224,1002,223,8,223,101,3,224,224,1,224,223,223,102,90,169,224,1001,224,-4590,224,4,224,1002,223,8,223,1001,224,1,224,1,224,223,223,1102,90,45,224,1001,224,-4050,224,4,224,102,8,223,223,101,5,224,224,1,224,223,223,1001,144,32,224,101,-72,224,224,4,224,102,8,223,223,101,3,224,224,1,223,224,223,1102,36,93,225,1101,88,52,225,1002,102,38,224,101,-3534,224,224,4,224,102,8,223,223,101,4,224,224,1,223,224,223,1102,15,57,225,1102,55,49,225,1102,11,33,225,1101,56,40,225,1,131,105,224,101,-103,224,224,4,224,102,8,223,223,1001,224,2,224,1,224,223,223,1102,51,39,225,1101,45,90,225,2,173,139,224,101,-495,224,224,4,224,1002,223,8,223,1001,224,5,224,1,223,224,223,1101,68,86,224,1001,224,-154,224,4,224,102,8,223,223,1001,224,1,224,1,224,223,223,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,100
@CharlotteGore
CharlotteGore / aoc_2019_3.js
Created December 3, 2019 17:28
AoC 2019 Day 3
// this is a var because I hack directly into chrome devtools for these and you can't redeclare consts and lets haha.
var day32019 = () => {
const start = performance.now();
const src = `R1005,U563,R417,U509,L237,U555,R397,U414,L490,U336,L697,D682,L180,U951,L189,D547,R697,U583,L172,D859,L370,D114,L519,U829,R389,U608,R66,D634,L320,D49,L931,U137,L349,D689,L351,D829,R819,D138,L118,D849,R230,U858,L509,D311,R815,U217,R359,U840,R77,U230,R361,U322,R300,D646,R348,U815,R793,D752,R967,U128,R948,D499,R359,U572,L566,U815,R630,D290,L829,D736,R358,U778,R891,U941,R544,U889,L920,U913,L447,D604,R538,U818,L215,D437,R447,U576,R452,D794,R864,U269,L325,D35,L268,D639,L101,U777,L776,U958,R105,U517,R667,D423,R603,U469,L125,D919,R879,U994,R665,D377,R456,D570,L685,U291,R261,U846,R840,U418,L974,D270,L312,D426,R621,D334,L855,D378,R694,U845,R481,U895,L362,D840,L712,U57,R276,D643,R566,U348,R361,D144,L287,D864,L556,U610,L927,U322,R271,D90,L741,U446,R181,D527,R56,U805,L907,D406,L286,U873,L79,D280,L153,D377,R253,D61,R475,D804,R788,U393,L
// load the webgl world..
var world = require('./world')(document.getElementById('screen'));
// load the level data (universe.json) into the universe module..
var universe = require('./mapper.js')(require('./universe.json'));
// initialise a map..
var level = universe.initialiseLevel('1-1');
// add the parallax meshes to the scene...
-----BEGIN PGP MESSAGE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org
hQIMA8DkYkPwMUUmAQ/9F33hrabHdkq57VmyM+eXkeigU8kJvbIrs29xSGMxac3b
16hxupfDQ3bQuqwj5FOTE8b27AVtioTevtTQOAD3Tg5M4MHnKHu4utE2rujPXqtd
i7PvMarVfLmgPZJ+9VEbuGLqeIcSIfZPrpSgZZV7cGPpMNRGClba2YMCI750AjWN
oALsAsmbNGQI1S/kjhH4FJo+moOQLL/XE8QFra5PG4k4i5VZx/m/IF8U0tlFKfnL
y2yfB7Kq5h+a2G+3hYWJK+/a9NaeDuXbVwZpQByXKn4xY5Aj5Ik5R+B+h2rED0H8
wSrgvaZ0f1Doi1kzWKScTRE8nqhEVBWWsZWREEElFYy7xKt/UMzjgxt+pvgjK7gJ
@CharlotteGore
CharlotteGore / gist:8603a5dfbd59f5d1ae47
Created January 13, 2015 13:37
This is about fish.
-----BEGIN PGP MESSAGE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org
hQIMA8DkYkPwMUUmAQ/+J0Z5ojoFDl9RSoTRAI7O33RnKqaBV9nwEpOo/c11WRlx
U8HA7vWbrgr5Q9XtfSl3TDNSnYOoBS0p7XqhaVh+ziQFUuha5Ry+AcuoBTaOlD/W
BlEFm9bRehoc9b52+Des2pv8Y6Z1Zc6fls9zm3qDwzWBHWaxXJXKh4uiMvjDaC8G
Fe3VZntq8Lhi+/2fPLjpVOLYcUiaU5zreDZ7nxSL8JoINit6LyTBu8byeRa88eJy
Ai3gMsydkPrrnvBplkO9ZQ9zUu3vcxMY/tJVWM6BMJ4v26FtgpDJR9JE4M5YB4jO
CwtMnw4tIoksU2V6Km6Bev4vUHqx4jhZEbosWIBA0TGXH11nNx5wMcXcBHwUx3hN
function Tiger (){
this.name = "Tiger King!";
return this;
}
Tiger.prototype.waitABitThenRoarMyName = function (){
setTimeout(function (){
alert('Rawr!!! I AM ' + this.name);
// namespace.js - first file you load...
(function (){
var TIGERWORLD = {};
window.TIGERWORLD = TIGERWORLD;
})();
// tiger.js - load this after namespace.js...
(function (TIGERWORLD){
function Tiger (){
this.name = "";
this.isKing = "";
return this;
}
Tiger.prototype = {
setName : function (name){
this.name = name;