Skip to content

Instantly share code, notes, and snippets.

View erikaderstedt's full-sized avatar

Erik Aderstedt erikaderstedt

View GitHub Profile
use crate::common::Solution;
use crate::common::parsed_from_each_line;
#[derive(Debug)]
struct Data {
level: i64,
consecutive_ones: usize,
seqs: [usize;4],
}
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()
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,
use crate::common::Solution;
use crate::grid::{Grid,GridElement,Position};
#[derive(Eq,PartialEq,Clone,Debug)]
enum ForestTile {
Open,
Tree,
}
impl GridElement for ForestTile {
#!/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")
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)]
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),
//
// 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"
//
// 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"
#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) {