reorganize data files, use data files for all days (even when not provided as download)

This commit is contained in:
Stefan Bühler 2020-12-26 10:37:15 +01:00
parent cebe864c8b
commit 5215f3bb5f
51 changed files with 30 additions and 30 deletions

View File

@ -4,6 +4,4 @@ version = "0.1.0"
authors = ["Stefan Bühler <stbuehler@web.de>"] authors = ["Stefan Bühler <stbuehler@web.de>"]
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]

1
data/day15 Normal file
View File

@ -0,0 +1 @@
5,2,8,16,18,0,1

1
data/day23 Normal file
View File

@ -0,0 +1 @@
315679824

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day1/input"); const INPUT: &str = include_str!("../../data/day1");
fn main() { fn main() {
let expenses: Vec<_> = INPUT.split_whitespace().map(|s| s.parse::<u32>().unwrap()).collect(); let expenses: Vec<_> = INPUT.split_whitespace().map(|s| s.parse::<u32>().unwrap()).collect();

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day10/input"); const INPUT: &str = include_str!("../../data/day10");
fn calc(input: &[u32], cache: &mut [Option<u64>], ndx: usize) -> u64 { fn calc(input: &[u32], cache: &mut [Option<u64>], ndx: usize) -> u64 {
if let Some(n) = cache[ndx] { if let Some(n) = cache[ndx] {

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day11/input"); const INPUT: &str = include_str!("../../data/day11");
#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum Cell { enum Cell {

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day12/input"); const INPUT: &str = include_str!("../../data/day12");
#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum Rotate { enum Rotate {

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day13/input"); const INPUT: &str = include_str!("../../data/day13");
struct Input { struct Input {
now: i128, now: i128,

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day14/input"); const INPUT: &str = include_str!("../../data/day14");
use std::collections::HashMap; use std::collections::HashMap;

View File

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
const INPUT: &str = "5,2,8,16,18,0,1"; const INPUT: &str = include_str!("../../data/day15");
struct Memory { struct Memory {
turn: usize, turn: usize,
@ -27,7 +27,7 @@ impl Memory {
} }
fn main() { fn main() {
let input: Vec<usize> = INPUT.split(",").map(|s| s.parse().unwrap()).collect(); let input: Vec<usize> = INPUT.trim().split(",").map(|s| s.parse().unwrap()).collect();
let mut mem = Memory::new(); let mut mem = Memory::new();
for &value in &input { for &value in &input {
mem.remember(value); mem.remember(value);

View File

@ -1,7 +1,7 @@
use std::ops::RangeInclusive; use std::ops::RangeInclusive;
use std::collections::{HashSet, HashMap}; use std::collections::{HashSet, HashMap};
const INPUT: &str = include_str!("../../data/day16/input"); const INPUT: &str = include_str!("../../data/day16");
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct Field { struct Field {

View File

@ -1,6 +1,6 @@
use std::ops::Range; use std::ops::Range;
const INPUT: &str = include_str!("../../data/day17/input"); const INPUT: &str = include_str!("../../data/day17");
#[derive(Clone, Copy, Default)] #[derive(Clone, Copy, Default)]
struct Dimension { struct Dimension {

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day18/input"); const INPUT: &str = include_str!("../../data/day18");
#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum Op { enum Op {

View File

@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::sync::Arc; use std::sync::Arc;
const INPUT: &str = include_str!("../../data/day19/input"); const INPUT: &str = include_str!("../../data/day19");
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
enum Rule { enum Rule {

View File

@ -1,6 +1,6 @@
use std::convert::TryInto; use std::convert::TryInto;
const INPUT: &str = include_str!("../../data/day2/input"); const INPUT: &str = include_str!("../../data/day2");
struct Policy { struct Policy {
min: usize, min: usize,

View File

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
const INPUT: &str = include_str!("../../data/day20/input"); const INPUT: &str = include_str!("../../data/day20");
#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)] #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)]
enum Side { enum Side {

View File

@ -1,6 +1,6 @@
use std::collections::{BTreeMap, HashMap, HashSet}; use std::collections::{BTreeMap, HashMap, HashSet};
const INPUT: &str = include_str!("../../data/day21/input"); const INPUT: &str = include_str!("../../data/day21");
struct FoodDescription<'a> { struct FoodDescription<'a> {
ingredients: HashSet<&'a str>, ingredients: HashSet<&'a str>,

View File

@ -2,7 +2,7 @@ use std::collections::{VecDeque, HashSet};
type Deck = VecDeque<u32>; type Deck = VecDeque<u32>;
const INPUT: &str = include_str!("../../data/day22/input"); const INPUT: &str = include_str!("../../data/day22");
fn parse_player(block: &str) -> (u32, Deck) { fn parse_player(block: &str) -> (u32, Deck) {
let block = block.strip_prefix("Player ").unwrap(); let block = block.strip_prefix("Player ").unwrap();

View File

@ -1,6 +1,6 @@
use std::mem::replace; use std::mem::replace;
const INPUT: &str = "315679824"; const INPUT: &str = include_str!("../../data/day23");
type Item = usize; type Item = usize;
@ -200,14 +200,14 @@ impl Cups {
} }
fn main() { fn main() {
let mut cups = Cups::parse(INPUT); let mut cups = Cups::parse(INPUT.trim());
for _ in 0..100 { for _ in 0..100 {
cups.mix(); cups.mix();
} }
cups.rotate_to_one(); cups.rotate_to_one();
println!("Cups: {}", cups.iter().skip(1).map(|c| format!("{}", c)).collect::<Vec<_>>().join("")); println!("Cups: {}", cups.iter().skip(1).map(|c| format!("{}", c)).collect::<Vec<_>>().join(""));
let mut cups = Cups::parse(INPUT); let mut cups = Cups::parse(INPUT.trim());
cups.extend(10..=1000000); cups.extend(10..=1000000);
for _ in 0..10000000 { for _ in 0..10000000 {
cups.mix() cups.mix()

View File

@ -1,6 +1,6 @@
use std::collections::HashSet; use std::collections::HashSet;
const INPUT: &str = include_str!("../../data/day24/input"); const INPUT: &str = include_str!("../../data/day24");
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
enum Direction { enum Direction {

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day25/input"); const INPUT: &str = include_str!("../../data/day25");
const MOD: u32 = 20201227; const MOD: u32 = 20201227;

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day3/input"); const INPUT: &str = include_str!("../../data/day3");
struct Forest { struct Forest {
pub rows: usize, pub rows: usize,

View File

@ -2,7 +2,7 @@ pub mod passport;
use passport::Passport; use passport::Passport;
const INPUT: &str = include_str!("../../../data/day4/input"); const INPUT: &str = include_str!("../../../data/day4");
fn main() { fn main() {
let passports = Passport::parse_list(INPUT); let passports = Passport::parse_list(INPUT);

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day5/input"); const INPUT: &str = include_str!("../../data/day5");
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
struct Seat { struct Seat {

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day6/input"); const INPUT: &str = include_str!("../../data/day6");
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
struct Answers { struct Answers {

View File

@ -1,6 +1,6 @@
use std::collections::{HashMap, HashSet, VecDeque}; use std::collections::{HashMap, HashSet, VecDeque};
const INPUT: &str = include_str!("../../data/day7/input"); const INPUT: &str = include_str!("../../data/day7");
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
struct BagId(usize); struct BagId(usize);

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day8/input"); const INPUT: &str = include_str!("../../data/day8");
#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum Instruction { enum Instruction {

View File

@ -1,4 +1,4 @@
const INPUT: &str = include_str!("../../data/day9/input"); const INPUT: &str = include_str!("../../data/day9");
// store sums of elems in different row and colum, but just once // store sums of elems in different row and colum, but just once
// | 0 | 1 | 2 | 3 | ... // | 0 | 1 | 2 | 3 | ...