2020-12-01 07:16:56 +01:00
#!/bin/sh
today = $( date +%d)
# this assumes that your puzzle input is already in your clipboard
2020-12-09 08:57:54 +01:00
xsel -b > inputs/day$today
2020-12-01 07:16:56 +01:00
# add trailing newline if necessary
2020-12-09 08:57:54 +01:00
sed -i -e '$a\' inputs/day$today
2020-12-03 10:24:03 +01:00
2020-12-09 08:57:54 +01:00
echo ' #![feature(test)]
2020-12-07 16:17:07 +01:00
extern crate test;
use std::env;
2020-12-10 12:44:07 +01:00
type Parsed = Vec<usize>;
2020-12-07 16:17:07 +01:00
fn read_input( ) -> String {
2020-12-10 12:44:07 +01:00
std::fs::read_to_string( env::args( ) .nth( 1) .filter( | n| n != "--bench" ) .unwrap_or_else( || String::from( " inputs/day' $today ' " ) ) ) .unwrap( )
}
fn parse_input( raw: & str) -> Parsed {
unimplemented!( )
2020-12-07 16:17:07 +01:00
}
2020-12-10 12:44:07 +01:00
fn part1( parsed: & Parsed) -> usize {
unimplemented!( )
}
fn part2( parsed: & Parsed) -> usize {
2020-12-07 16:17:07 +01:00
unimplemented!( )
}
fn main( ) {
let input = parse_input( & read_input( ) ) ;
println!( "Part 1: {}" , part1( & input) ) ;
println!( "Part 2: {}" , part2( & input) ) ;
2020-12-05 09:50:09 +01:00
}
#[cfg(test)]
mod tests {
use super::*;
use test::black_box;
2020-12-07 16:17:07 +01:00
const TEST_INPUT: & str = "" ;
2020-12-10 12:44:07 +01:00
#[test]
fn part1_test( ) {
let input = parse_input( TEST_INPUT) ;
assert_eq!( part1( & input) , 0) ;
}
#[test]
fn part2_test( ) {
let input = parse_input( TEST_INPUT) ;
assert_eq!( part2( & input) , 0) ;
}
#[bench]
fn bench_input_parsing( b: & mut test::Bencher) {
let raw = read_input( ) ;
b.iter( || parse_input( black_box( & raw) ) )
}
#[bench]
fn bench_part1( b: & mut test::Bencher) {
let input = parse_input( & read_input( ) ) ;
b.iter( || assert_eq!( part1( black_box( & input) ) , 0) ) ;
}
#[bench]
fn bench_part2( b: & mut test::Bencher) {
let input = parse_input( & read_input( ) ) ;
b.iter( || assert_eq!( part2( black_box( & input) ) , 0) ) ;
}
2020-12-09 08:57:54 +01:00
} ' > src/bin/day$today .rs