Skip to content

Instantly share code, notes, and snippets.

@JPMoresmau
Created February 10, 2019 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPMoresmau/2f8c58c8973de1df8cea65f419720539 to your computer and use it in GitHub Desktop.
Save JPMoresmau/2f8c58c8973de1df8cea65f419720539 to your computer and use it in GitHub Desktop.
Lovecraft: parse_grid
pub fn parse_grid(grid_desc :&str) -> Grid {
let mut grid: Grid = [[false;4];4];
grid_desc.chars().collect::<Vec<char>>().chunks(4).
enumerate().for_each(|(a,cs)| {
cs.iter().enumerate().for_each(|(b,c)| {
if *c == '1' {
grid[a][b]=true;
}
})
});
grid
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment