<commit_before>use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;

pub fn obsecurity_1(file: &str) -> usize {
    parse_rooms(file)
}

pub fn obsecurity_2(file: &str) -> usize {
    parse_rooms(file)
}

fn parse_rooms(file: &str) -> usize {
    let input = File::open(file).expect("File open fail.");
    let reader = BufReader::new(input);

    let lines: Vec<String> = reader.lines()
        .filter_map(Result::ok)
        .collect();

    for line in lines {
        let words = line.split("-").collect::<Vec<&str>>();
        println!("{:?}", words);
    }
    9
}

struct Room {
    words: Vec<String>,
    id: usize,
    checksum: String,
}
<commit_msg>Progress splitting up into chars.<commit_after>use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::collections::BTreeMap;

pub fn obsecurity_1(file: &str) -> usize {
    parse_rooms(file)
}

pub fn obsecurity_2(file: &str) -> usize {
    parse_rooms(file)
}

fn parse_rooms(file: &str) -> usize {
    let input = File::open(file).expect("File open fail.");
    let reader = BufReader::new(input);

    let lines: Vec<String> = reader.lines()
        .filter_map(Result::ok)
        .collect();

    let mut sum = 0;
    for line in lines {
        let mut words = line.split("-").collect::<Vec<&str>>();

        if let Some(id_checksum) = words.pop() {
            if let Some(i) = id_checksum.find("[") {
                let (id, checksum) = id_checksum.split_at(i);
                let checksum = checksum.trim_matches(|c| c == '[' || c == ']')
                    .split("")
                    .flat_map(str::chars)
                    .collect::<Vec<char>>();
                println!("{} {:?}", id, checksum);
                let letters = words.iter().flat_map(|s| s.chars()).collect::<Vec<char>>();
                println!("{:?}", letters);
                let mut count = BTreeMap::new();
                for c in letters {
                    *count.entry(c).or_insert(0) += 1;
                }
                if let Ok(id) = id.parse::<usize>() {
                    sum += id;
                }
            }
        };
    }
    9
}

{'fraction_non_alphanumeric': 0.1770446096654275, 'fraction_numerical': 0.004182156133828996, 'mean_word_length': 2.093390804597701, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7512185', 'n_tokens_mistral': 715, 'n_tokens_neox': 703, 'n_words': 154}