Revert "Use a constant vector for the sudoku board, delete a FIXME"

This reverts commit 06d0bf7555c55dc6c9d5b9945c06d30d0edf090b.
This commit is contained in:
Tim Chevalier 2012-10-11 18:08:58 -07:00
parent 55b528484d
commit 44bffd2059

View File

@ -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())
};