Created
December 29, 2017 17:03
-
-
Save tbelaire/670ab192589311ba114b4b63d2cc681d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use ndarray::{Array, Array2}; | |
fn parse(input: &str) -> Array2<u8> { | |
let width = input.lines().next().unwrap().len(); | |
let height = input.lines().count(); | |
println!("Parsing input"); | |
for line in input.lines() { | |
println!("#{}#, ({})", line, line.len()); | |
} | |
println!("input is {}x{}, a total of {}", width, height, input.len()); | |
let m = Array::from_iter(input.lines().flat_map(|l| l.as_bytes().iter().cloned())); | |
let m = m.into_shape([width, height]).unwrap(); | |
m | |
} | |
#[test] | |
fn test_parse() { | |
let input = r" | |
| | |
| +--+ | |
A | C | |
F---|----E|--+ | |
| | | D | |
+B-+ +--+ "[1..].to_string(); | |
let m = parse(&input); | |
assert_eq!(m.shape(), [15, 6]); | |
} | |
fn find_start(maze: &Array2<u8>) -> (usize, usize) { | |
(0,0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment