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
Environment* CreateEnvironment(Isolate* isolate, uv_loop_t* loop, Handle<Context> context, int argc, const char* const* argv, int exec_argc, const char* const* exec_argv) { | |
HandleScope handle_scope(isolate); | |
Context::Scope context_scope(context); | |
Environment* env = Environment::New(context, loop); | |
isolate->SetAutorunMicrotasks(false); | |
uv_check_init(env->event_loop(), env->immediate_check_handle()); | |
uv_unref(reinterpret_cast<uv_handle_t*>(env->immediate_check_handle())); |
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
'use strict'; | |
const CURRENT_YEAR = 2015; | |
// Generator that shifts days by bits | |
function* developersDayGenerator() { | |
let day = 1; | |
while (day < 365) { | |
yield day; | |
day = day << 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
'use strict'; | |
import fs from 'fs'; | |
import program from 'commander'; | |
import Speaker from 'speaker'; | |
import { Decoder } from 'lame'; | |
import Parser from 'icecast-parser'; | |
program | |
.option('-s, --source <source>', 'Source station') |
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 fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split(''); | |
const result = INPUT.reduce((floor, direction) => direction === '(' ? ++floor : --floor, 0); | |
console.log(result); |
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 fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split(''); | |
let floor = 0; | |
let result = INPUT.map(direction => direction === '(' ? ++floor : --floor).indexOf(-1) + 1; | |
console.log(result); |
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 fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split('\n'); | |
const result = INPUT.reduce((total, _lwh) => { | |
const lwh = _lwh.split('x'); | |
const length = lwh[0]; | |
const width = lwh[1]; | |
const height = lwh[2]; | |
return total | |
+ (2 * length * width) |
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 fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split('\n'); | |
const result = INPUT.reduce((total, _lwh) => { | |
const lwh = _lwh.split('x').map(Number).sort((a, b) => a - b); | |
return total | |
+ (lwh[0] + lwh[0] + lwh[1] + lwh[1]) | |
+ (lwh[0] * lwh[1] * lwh[2]) | |
}, 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
const fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split(''); | |
// Unique set of coordinates with the starting coordinates already added | |
const coordinates = new Set().add(`0x0`); | |
INPUT.reduce((curCoords, direction) => { | |
let newCoords = {x: 0, y: 0}; | |
if (direction === '^') newCoords = {x: curCoords.x, y: curCoords.y + 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
const fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split(''); | |
const santaDirections = INPUT.filter((item, index) => index % 2 === 0); | |
const roboSantaDirections = INPUT.filter((item, index) => index % 2 === 1); | |
// Get array of directions and return array of visited coordinates | |
const traverse = directions => { | |
let visitedCoordinates = ['0x0']; | |
let currentPosition = {x: 0, y: 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
const crypto = require('crypto'); | |
const INPUT = 'ckczppom'; | |
const md5 = data => crypto.createHash('md5').update(data).digest('hex'); | |
const isStartsWithFiveZeros = data => data.slice(0, 5) === '00000'; | |
let counter = 0; | |
while (!isStartsWithFiveZeros(md5(`${INPUT}${counter}`))) counter++; | |
console.log(counter); |