<commit_before>#[allow(dead_code)]
mod die;
#[allow(dead_code)]
mod probs;
#[allow(dead_code)]
mod puntata;

use crate::{die::Die,probs::get_probs_of,puntata::Puntata};
use std::io;

fn read_int() -> i32 {
    let mut input_text = String::new();

    io::stdin()
        .read_line(&mut input_text)
        .expect("failed to read from stdin");

    let trimmed = input_text.trim();
    trimmed.parse::<i32>().expect("Invalid integer!")
}

fn main() {
    println!("Enter players' other dices count:");

    let dice = read_int();
    let mut my_dice = vec![];

    for _ in 0..5 {
        let dice = read_int();

        my_dice.push(Die::new(dice));
    }

    println!("My dice: {:?}", my_dice);

    let p = Puntata::new(4, 5);

    let all_probs = get_probs_of(dice, &my_dice, false, &p);

    let mut sorted_all_probs: Vec<_> = all_probs.into_iter().collect();

    sorted_all_probs.sort_by(|&(_, v1), &(_, v2)| v1.partial_cmp(&v2).unwrap().reverse());

    let prob_of_p = {
        let t = sorted_all_probs.iter().find(|&&(p1, _)| p1 == p).unwrap();
        t.1
    };

    sorted_all_probs.retain(|&(px, _)| px != p);

    println!("Probability of {}: {1:.2}%", p, prob_of_p * 100.0);

    if prob_of_p <= 0.2 {
        println!("I would dubitate...");
    } else {
        println!(
            "I would play {}, with chance {1:.2}%",
            sorted_all_probs[0].0,
            sorted_all_probs[0].1 * 100.0
        );
    }

    println!();
    println!("List of all probs:");<commit_msg>fixed main due to the introduction of lexical scopes<commit_after>#[allow(dead_code)]
mod die;
#[allow(dead_code)]
mod probs;
#[allow(dead_code)]
mod puntata;

use crate::{die::Die,probs::get_probs_of,puntata::Puntata};
use std::io;

fn read_int() -> i32 {
    let mut input_text = String::new();

    io::stdin()
        .read_line(&mut input_text)
        .expect("failed to read from stdin");

    let trimmed = input_text.trim();
    trimmed.parse::<i32>().expect("Invalid integer!")
}

fn main() {
    println!("Enter players' other dices count:");

    let dice = read_int();
    let mut my_dice = vec![];

    for _ in 0..5 {
        let dice = read_int();

        my_dice.push(Die::new(dice));
    }

    println!("My dice: {:?}", my_dice);

    let p = Puntata::new(4, 5);

    let all_probs = get_probs_of(dice, &my_dice, false, &p);

    let mut sorted_all_probs: Vec<_> = all_probs.into_iter().collect();

    sorted_all_probs.sort_by(|&(_, v1), &(_, v2)| v1.partial_cmp(&v2).unwrap().reverse());

    let t = sorted_all_probs.iter().find(|&&(p1, _)| p1 == p).unwrap();
    let prob_of_p = t.1;

    sorted_all_probs.retain(|&(px, _)| px != p);

    println!("Probability of {}: {1:.2}%", p, prob_of_p * 100.0);

    if prob_of_p <= 0.2 {
        println!("I would dubitate...");
    } else {
        println!(
            "I would play {}, with chance {1:.2}%",
            sorted_all_probs[0].0,
            sorted_all_probs[0].1 * 100.0
        );
    }

    println!();
    println!("List of all probs:");
{'fraction_non_alphanumeric': 0.1890909090909091, 'fraction_numerical': 0.02181818181818182, 'mean_word_length': 2.8547770700636943, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3651708', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1155, 'n_words': 237}