This file contains hidden or 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
#!/usr/bin/env python3 | |
import math | |
import itertools | |
class Stats(object): | |
def __init__(self, hp, damage, armor): | |
self.hit_points = hp | |
self.damage = damage | |
self.armor = armor |
This file contains hidden or 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::fs::File; | |
use std::io::BufReader; | |
use std::io::BufRead; | |
use std::collections::{HashMap, VecDeque}; | |
// Applies each transformation rule once on s | |
fn transform(s: &str, replacements: &Vec<(String, String)>) -> Vec<String> { | |
let mut results: Vec<String> = Vec::new(); | |
for &(ref to, ref from) in replacements.iter() { | |
for (ix, _) in s.match_indices(from) { |
This file contains hidden or 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::fs::File; | |
use std::io::BufReader; | |
use std::io::BufRead; | |
use std::collections::HashSet; | |
fn main() { | |
let input_fname = "day19_input.txt"; | |
let f = File::open(input_fname).unwrap(); | |
let mut replacements: Vec<(String, String)> = Vec::new(); |
This file contains hidden or 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
extern crate serde; // 0.6.6 | |
extern crate serde_json; // 0.6.0 | |
use std::fs::File; | |
use std::io::BufReader; | |
use serde_json::Value as Value; | |
fn sum_numbers(json: &Value) -> i64 { | |
match *json { | |
Value::I64(n) => n as i64, |
This file contains hidden or 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
#![feature(plugin)] | |
#![plugin(regex_macros)] | |
extern crate regex; | |
use std::fs::File; | |
use std::io::BufReader; | |
use std::io::BufRead; | |
fn passes_rule_1(s: &str) -> bool { |
This file contains hidden or 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
extern crate regex; | |
extern crate permutohedron; | |
use std::fs::File; | |
use std::io::BufReader; | |
use std::io::BufRead; | |
use std::collections::{HashMap, HashSet}; | |
use regex::Regex; | |
use permutohedron::LexicalPermutation; |
This file contains hidden or 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::fs::File; | |
use std::io::BufReader; | |
use std::io::BufRead; | |
use std::collections::HashMap; | |
#[derive(Debug)] | |
struct Wire { | |
source: WireSource, | |
target: String, | |
} |
This file contains hidden or 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
#!/usr/bin/env python | |
import os | |
import random | |
from itertools import izip | |
def get_neighbors(coords): | |
neighbors = set() | |
for (x, y) in coords: | |
neighbors.update( |
NewerOlder