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
/** | |
* There's no real reason to use this. Buffer is available in node: | |
* | |
* Buffer.from(typedArray.buffer).toString('base64'); | |
* | |
* and the browser has atob/btoa (which are fine to use for the ascii | |
* characters used to represent bytes. | |
*/ | |
function byteToBin(byte) { |
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
Show hidden characters
{ | |
"env": { | |
"mocha": true | |
}, | |
"rules": { | |
"max-nested-callbacks": ["error", 7], | |
"no-restricted-properties": [ | |
"error", | |
{ "object": "describe", "property": "only" }, | |
{ "object": "context", "property": "only" }, |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<script type="module" src="index.js"></script> | |
<title>Game of Life</title> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<h1>Game of Life</h1> | |
<canvas width="600" height="600"></canvas> |
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
[package] | |
name = "task-1" | |
version = "0.1.0" | |
authors = ["Mark S. Everitt <[email protected]>"] | |
edition = "2018" | |
[dependencies] | |
recap = "0.1" | |
serde = "1.0.90" |
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
[package] | |
name = "task-1" | |
version = "0.1.0" | |
authors = ["Mark S. Everitt <[email protected]>"] | |
edition = "2018" | |
[dependencies] | |
regex = "1" | |
lazy_static = "1.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
use std::io::{self, BufRead}; | |
use std::str; | |
struct Node { | |
children: Vec<Box<Node>>, | |
metadata: Vec<usize> | |
} | |
impl Node { | |
fn evaluate(&self) -> usize { |
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 regex::Regex; | |
use std::io::{stdin, BufRead}; | |
use std::cmp::{max}; | |
#[macro_use] | |
extern crate lazy_static; | |
const MAX_TOTAL_DIST: usize = 10000; | |
fn abs_diff(a: &usize, b: &usize) -> usize { |
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 std::io::{stdin, BufRead}; | |
use std::collections::BTreeSet; | |
fn main() { | |
let shifts: Vec<i32> = stdin().lock() | |
.lines() | |
.filter_map(|line| line.unwrap().parse().ok()) | |
.collect(); | |
let mut frequency = 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
'use strict'; | |
const rawInput = require('fs').readFileSync(process.argv[2], 'utf8').trim().split('\n'); | |
const input = rawInput.map(line => { | |
const [p, v, a] = line.split(', ').map(part => part.slice(3, -1).split(',').map(n => parseInt(n, 10))); | |
return { p, v, a }; | |
}); | |
function isNaturalNumber(num) { |
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
// Usage: node advent-of-code-2017-d04p2-boring.js /path/to/input.txt | |
// This boring version works by lexicographically sorting the characters | |
// in each word of the pass phrase, and then adding them all to a set. | |
// If the size of the set is less than the number of words in the | |
// passphrase, then at least one pair of words were anagrams of each | |
// other and the passphrase invalid. | |
'use strict'; |
NewerOlder