coctus 0.3.0

Command line tool for playing CodinGame puzzles and Clash of Code
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::path::PathBuf;

use anyhow::{Context, Result};
use clash::Clash;

use super::*;

pub fn sample_puzzle(name: &str) -> Result<Clash> {
    let puzzle_file: PathBuf = ["fixtures", "puzzles", format!("{}.json", name).as_str()].iter().collect();
    let contents = std::fs::read_to_string(&puzzle_file)
        .with_context(|| format!("Unable to test puzzle with name {}", name))?;
    let clash: Clash = serde_json::from_str(&contents)
        .with_context(|| format!("Unable to deserialize test puzzle {} from {:?}", name, &puzzle_file))?;

    Ok(clash)
}