Skip to content

Instantly share code, notes, and snippets.

@JPMoresmau
Created February 10, 2019 15:22
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/943a4e4b1546ed44896b986b81800b62 to your computer and use it in GitHub Desktop.
Save JPMoresmau/943a4e4b1546ed44896b986b81800b62 to your computer and use it in GitHub Desktop.
Lovecraft: swap
fn swap(grid: &Grid, pos: Pos) -> Grid {
let mut grid = grid.clone();
for a in 0..4 {
grid[pos.0][a] = !grid[pos.0][a];
}
for a in 0..4 {
grid[a][pos.1] = !grid[a][pos.1];
}
grid[pos.0][pos.1] = !grid[pos.0][pos.1];
grid
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment