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 crate::common::Solution; | |
use crate::common::parsed_from_each_line; | |
#[derive(Debug)] | |
struct Data { | |
level: i64, | |
consecutive_ones: usize, | |
seqs: [usize;4], | |
} |
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 crate::common::Solution; | |
use std::collections::BTreeMap; | |
type PassportInformation<'a> = BTreeMap<&'a str,&'a str>; | |
pub fn solve(lines: &[String]) -> Solution { | |
let s = lines.join("\n"); | |
let passports: Vec<PassportInformation> = s.split("\n\n") | |
.map(|pwd_fields| pwd_fields | |
.split_whitespace() |
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::marker::Sized; | |
use std::ops::{Index,IndexMut}; | |
use std::cmp::{PartialEq,Eq}; | |
pub trait GridElement: Sized + PartialEq + Eq + Clone { | |
fn from_char(c: &char) -> Option<Self>; | |
} | |
pub struct Grid<T: GridElement> { | |
pub rows: 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 crate::common::Solution; | |
use crate::grid::{Grid,GridElement,Position}; | |
#[derive(Eq,PartialEq,Clone,Debug)] | |
enum ForestTile { | |
Open, | |
Tree, | |
} | |
impl GridElement for ForestTile { |
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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
from aocd import data | |
from re import compile | |
import sys | |
cut = compile("cut (-?\d+)") | |
deal_with_increment = compile("deal with increment (\d+)") | |
deal_into_new_stack = compile("deal into new stack") |
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
import Foundation | |
struct Position: Hashable { | |
let x: Int | |
let y: Int | |
var adjacent: [Position] { | |
return [Position(x: x-1, y: y), | |
Position(x: x+1, y: y), | |
Position(x: x, y: y-1), | |
Position(x: x, y: 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
import Foundation | |
struct Position: Hashable { | |
let x: Int | |
let y: Int | |
let depth: Int | |
var adjacent: [Position] { | |
return [Position(x: x-1, y: y, depth: depth), | |
Position(x: x+1, y: y, depth: depth), |
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
// | |
// main.c | |
// p17 | |
// | |
// Created by Erik Aderstedt on 2019-12-16. | |
// Copyright © 2019 Aderstedt Software AB-> All rights reserved. | |
// | |
#include <stdio.h> | |
#include "intcode.h" |
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
// | |
// main.c | |
// p17 | |
// | |
// Created by Erik Aderstedt on 2019-12-16. | |
// Copyright © 2019 Aderstedt Software AB-> All rights reserved. | |
// | |
#include <stdio.h> | |
#include "intcode.h" |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#include "intcode.h" | |
#define MAX_NUM_OUTPUTS 10 | |
int find_oxygen_generator(int64_t x, int64_t y, int64_t *visited, size_t *num_visited, struct program *p, int nsteps, | |
struct program **drone_at_oxygen_generator, int64_t *generator_x, int64_t *generator_y) { |
NewerOlder