25 lines
No EOL
855 B
Rust
25 lines
No EOL
855 B
Rust
use db::LayoutDB;
|
|
use city::City;
|
|
use itertools::Itertools;
|
|
|
|
mod city;
|
|
mod db;
|
|
mod combine;
|
|
|
|
fn main() {
|
|
let mut db = LayoutDB::from_file("layouts.sqlite").expect("Failed to load the DB");
|
|
eprintln!("Loaded the DB, {} stored layouts", db.layouts().len());
|
|
|
|
let city = City::read_from_file("01.in");
|
|
eprintln!("Loaded the city file, {} houses", city.get_house_count());
|
|
|
|
let layouts = db.layouts();
|
|
let sorted: Vec<_> = layouts.iter().sorted_by(|x, y| city::get_price(&city, x.houses()).cmp(&city::get_price(&city, y.houses()))).collect();
|
|
|
|
const TOP_LAYOUT_COUNT: usize = 10;
|
|
|
|
let chosen_layouts = sorted.iter().take(TOP_LAYOUT_COUNT).map(|l| l.houses()).collect();
|
|
eprintln!("Starting to combine {} top houses DB; vertical cuts", TOP_LAYOUT_COUNT);
|
|
|
|
combine::try_combine(&city, &chosen_layouts, &chosen_layouts);
|
|
} |