pivot to rust

This commit is contained in:
Ben Kyd
2022-12-15 00:24:12 +00:00
parent 25cab0988f
commit 9f27d43154
6 changed files with 58 additions and 0 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@
.exe/ .exe/
.o/ .o/
*.o *.o
*target/

2
2022/rs/14.input Normal file
View File

@@ -0,0 +1,2 @@
498,4 -> 498,6 -> 496,6
503,4 -> 502,4 -> 502,9 -> 494,9

7
2022/rs/Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rs"
version = "0.1.0"

8
2022/rs/Cargo.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

32
2022/rs/src/day_14.rs Normal file
View File

@@ -0,0 +1,32 @@
use std::collections::HashMap;
const CHALLENGE_INPUT: &str = include_str!("../14.input");
const EXAMPLE_INPUT: &str = "498,4 -> 498,6 -> 496,6\n503,4 -> 502,4 -> 502,9 -> 494,9";
enum Tile {
Foreground,
Background,
Sand,
}
struct Map {
min_x: i32,
max_x: i32,
min_y: i32,
max_y: i32,
tiles: HashMap<(i32, i32), Tile>,
}
pub fn part_1() -> &'static str {
return EXAMPLE_INPUT;
}
#[cfg(test)]
mod test {
use crate::day_14;
#[test]
fn part1_test() {
assert_eq!(day_14::part_1(), day_14::EXAMPLE_INPUT);
}
}

8
2022/rs/src/main.rs Normal file
View File

@@ -0,0 +1,8 @@
#![allow(dead_code)]
#![allow(unused_variables)]
mod day_14;
fn main() {
day_14::part_1();
}