Sort residents by least flexibility first

This commit is contained in:
2026-02-28 10:00:35 +02:00
parent ab41e8f264
commit 934e2c2fd2
2 changed files with 39 additions and 15 deletions

View File

@@ -17,8 +17,8 @@ const YEAR: i32 = 2026;
pub struct ToxicPair((ResidentId, ResidentId));
impl ToxicPair {
pub fn new(res_id_1: u8, res_id_2: u8) -> Self {
Self((ResidentId(res_id_1), ResidentId(res_id_2)))
pub fn new(r_id_1: u8, r_id_2: u8) -> Self {
Self((ResidentId(r_id_1), ResidentId(r_id_2)))
}
pub fn matches(&self, other: &ToxicPair) -> bool {
@@ -134,6 +134,14 @@ impl UserConfig {
}
supply
}
pub fn flexibility_map(&self) -> HashMap<ResidentId, u8> {
let mut map = HashMap::new();
for r in &self.residents {
map.insert(r.id, r.allowed_types.len() as u8);
}
map
}
}
impl Default for UserConfig {