Skip to content

Commit

Permalink
Revert "Use a constant vector for the sudoku board, delete a FIXME"
Browse files Browse the repository at this point in the history
This reverts commit 06d0bf7.
  • Loading branch information
catamorphism committed Oct 12, 2012
1 parent 55b5284 commit 44bffd2
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions src/test/bench/sudoku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,40 @@ fn write_grid(f: io::Writer, g: grid_t) {
}
}

const default_grid: [[u8]] = [[0, 4, 0, 6, 0, 0, 0, 7, 2, 0], //0
[0, 0, 8, 0, 2, 0, 0, 0, 0, 0], //1
[7, 0, 0, 8, 0, 0, 0, 0, 0, 0], //2
[0, 0, 0, 5, 0, 0, 0, 0, 0, 0], //3
[0, 5, 0, 0, 0, 3, 6, 0, 0, 0], //4
[6, 8, 0, 0, 0, 0, 0, 9, 0, 0], //5
[0, 9, 5, 0, 0, 6, 0, 7, 0, 0], //6
[0, 0, 0, 0, 4, 0, 0, 6, 0, 0], //7
[4, 0, 0, 0, 0, 7, 2, 0, 3, 0], //8
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];

fn main() {
let args = os::args();
let grid = if args.len() == 1 {
default_grid;
let grid = if vec::len(args) == 1u {
// FIXME create sudoku inline since nested vec consts dont work yet
// (#571)
let g = vec::from_fn(10u, |_i| {
vec::to_mut(vec::from_elem(10u, 0 as u8))
});
g[0][1] = 4u8;
g[0][3] = 6u8;
g[0][7] = 3u8;
g[0][8] = 2u8;
g[1][2] = 8u8;
g[1][4] = 2u8;
g[2][0] = 7u8;
g[2][3] = 8u8;
g[3][3] = 5u8;
g[4][1] = 5u8;
g[4][5] = 3u8;
g[4][6] = 6u8;
g[5][0] = 6u8;
g[5][1] = 8u8;
g[5][7] = 9u8;
g[6][1] = 9u8;
g[6][2] = 5u8;
g[6][5] = 6u8;
g[6][7] = 7u8;
g[7][4] = 4u8;
g[7][7] = 6u8;
g[8][0] = 4u8;
g[8][5] = 7u8;
g[8][6] = 2u8;
g[8][8] = 3u8;
grid_ctor(g)
} else {
read_grid(io::stdin())
};
Expand Down

0 comments on commit 44bffd2

Please sign in to comment.