Skip to content

Commit

Permalink
Template files, CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lpenz committed Nov 26, 2023
1 parent b4e7a73 commit f6c62fe
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: CI
on: [ workflow_dispatch, push, pull_request ]
jobs:
omnilint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: docker://lpenz/omnilint:0.5.1
rust:
uses: lpenz/ghworkflow-rust/.github/workflows/rust.yml@v0.18.0
with:
coveralls: true
publish_cratesio: false
publish_github_release: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
256 changes: 256 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]
members = [
"aoc",
"day00-template",
]

19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
![AoC](https://img.shields.io/badge/AoC%20%E2%AD%90-0-yellow)
[![CI](https://github.com/lpenz/adventofcode2023/workflows/CI/badge.svg)](https://github.com/lpenz/adventofcode2023/actions)
[![coveralls](https://coveralls.io/repos/github/lpenz/adventofcode2023/badge.svg?branch=main)](https://coveralls.io/github/lpenz/adventofcode2023?branch=main)

# adventofcode2023
Code for the 2022 puzzles at https://adventofcode.com/2023/

Code for the 2023 puzzles at https://adventofcode.com/2023/


## Noteworthy days (spoiler alert!)

Some interesting things that happened on specific days:



<table><tr>
<td><a href="https://github.com/lpenz/adventofcode2022">:arrow_left: 2022</td>
</tr></table>

8 changes: 8 additions & 0 deletions aoc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "aoc"
version = "0.1.0"
edition = "2021"

[dependencies]
color-eyre = "0.6.2"
nom = "7.1.3"
23 changes: 23 additions & 0 deletions aoc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#[macro_use]
pub mod parser {
pub use color_eyre::eyre::eyre;
pub use color_eyre::Result;
pub use nom::branch;
pub use nom::bytes::complete as bytes;
pub use nom::character::complete as character;
pub use nom::combinator;
pub use nom::multi;
pub use nom::Finish;
pub use nom::IResult;
pub use std::io::BufRead;

#[macro_export]
macro_rules! parse_with {
($parser:expr, $buf:ident) => {{
let mut input = String::default();
$buf.read_to_string(&mut input)?;
let result = combinator::all_consuming($parser)(&input).finish();
Ok(result.map_err(|e| eyre!("error reading input: {:?}", e))?.1)
}};
}
}
9 changes: 9 additions & 0 deletions day00-template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "day00"
version = "0.1.0"
edition = "2021"

[dependencies]
aoc = { path = "../aoc" }
color-eyre = "0.6.2"
nom = "7.1.3"
24 changes: 24 additions & 0 deletions day00-template/src/bin/day00a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2023 Leandro Lisboa Penz <lpenz@lpenz.org>
// This file is subject to the terms and conditions defined in
// file 'LICENSE', which is part of this source code package.

use std::io::{stdin, BufRead};

use day00::*;

fn process(bufin: impl BufRead) -> Result<usize> {
let input = parser::parse(bufin)?;
Ok(input.len())
}

#[test]
fn test() -> Result<()> {
assert_eq!(process(EXAMPLE.as_bytes())?, 1);
Ok(())
}

fn main() -> Result<()> {
color_eyre::install()?;
println!("{}", process(stdin().lock())?);
Ok(())
}
Loading

0 comments on commit f6c62fe

Please sign in to comment.