|
@@ -101,8 +101,8 @@ fn generate_part(arr: &[(i8, i8, i8)]) -> Part {
|
|
|
return v;
|
|
|
}
|
|
|
|
|
|
-pub fn generate_parts() -> HashMap<PartID, Part> {
|
|
|
- HashMap::from([
|
|
|
+pub fn generate_parts() -> Vec<(PartID, Part)> {
|
|
|
+ vec![
|
|
|
(1, generate_part(&[(0,1,1), (0,0,1), (1,0,1), (1,0,0), (2,0,0), (1,-1,1)])),
|
|
|
(2, generate_part(&[(0,1,1), (0,1,0), (0,0,1), (1,0,1), (1,0,0), (2,0,0)])),
|
|
|
(3, generate_part(&[(0,1,1), (0,0,1), (1,0,1), (1,0,0), (2,0,0), (2, -1, 0)])),
|
|
@@ -110,7 +110,7 @@ pub fn generate_parts() -> HashMap<PartID, Part> {
|
|
|
(5, generate_part(&[(0,1,1), (0,1,0), (1,1,0), (1,1,-1), (0,0,1), (0,0,2)])),
|
|
|
(6, generate_part(&[(0,1,1), (0,0,1), (1,0,1), (1,-1,1), (2,-1,1), (1,-1,2)])),
|
|
|
(7, generate_part(&[(0,1,1), (0,0,1), (1,0,1), (1,0,0), (1,1,0), (2,0,0)])),
|
|
|
- ])
|
|
|
+ ]
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -266,12 +266,12 @@ fn erase_part(map: &mut Map, part: &Part, x: i8, y: i8, rotation: u8, flipped: b
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-pub fn solve(map: &mut Map, parts: &[(PartID, &Part)]) -> Option<()>{
|
|
|
+pub fn solve(map: &mut Map, parts: &[(PartID, Part)]) -> Option<()>{
|
|
|
if parts.len() == 0 {
|
|
|
return Some(());
|
|
|
}
|
|
|
|
|
|
- let (id, part) = parts[0];
|
|
|
+ let (id, part) = &parts[0];
|
|
|
|
|
|
// TODO: restrict to list of non-barrier position to tighten the for loops
|
|
|
for y in 0..MAP_HEIGHT {
|
|
@@ -286,7 +286,7 @@ pub fn solve(map: &mut Map, parts: &[(PartID, &Part)]) -> Option<()>{
|
|
|
|
|
|
if valid_position {
|
|
|
// Place our part and try the others
|
|
|
- place_part(map, id, &part, x, y, rotation, flipped);
|
|
|
+ place_part(map, *id, &part, x, y, rotation, flipped);
|
|
|
print_map(&map);
|
|
|
|
|
|
if let Some(()) = solve(map, &parts[1..]) {
|