use db::{SqliteLayoutDB, SavedLayout};
use city::{City, House};
use itertools::Itertools;
use crate::combine::transpose_layout;

mod city;
mod db;
mod combine;

fn main() {
    let mut db = SqliteLayoutDB::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", city::INPUT_CITY_WIDTH, city::INPUT_CITY_HEIGHT);
    eprintln!("Loaded the city file, {} houses", city.get_house_count());

    const TOP_LAYOUT_COUNT: usize = 1500;

    let mut cache = combine::CompatibilityCache::new();

    combine::iterate_combines(&mut db, TOP_LAYOUT_COUNT, &city, &mut cache, true)
}