Created
February 10, 2019 15:24
-
-
Save JPMoresmau/2f8c58c8973de1df8cea65f419720539 to your computer and use it in GitHub Desktop.
Lovecraft: parse_grid
This file contains 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
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