pub fn gen_tasks(seed: u64) -> Vec<Self> {
        if TASKS_AMOUNT > 5 {
            panic!("There is only 5 tasks. Cannot generate more than that!");
        }

        let mut tasks_given = Vec::<u8>::new();
        let mut rng = Pcg64::seed_from_u64(seed);

        for _ in 0..TASKS_AMOUNT {
            // ToDo: replace the task assignment with something more optimal
            let mut id = rng.gen_range(0..5);
            while tasks_given.contains(&id) {
                id = rng.gen_range(0..5);
            }
            tasks_given.push(id);
        }

        let mut tasks_generated = Vec::<Self>::new();

        for task_id in tasks_given {
            match task_id {
                0 => {
                    let amount: u8 = rng.gen_range(2..6);
                    let mut numbers = Vec::new();
                    let mut result = 0;

                    for _ in 0..amount {
                        let number = rng.gen_range(NUM_MIN..NUM_MAX);
                        result = gcd(result, number);
                        numbers.push(number);
                    }

                    tasks_generated.push(Self::GCD {
                        numbers,
                        result,
                    });
                },
                1 => {
                    let num1 = rng.gen_range(NUM_MIN..NUM_MAX);
                    let num2 = rng.gen_range(NUM_MIN..NUM_MAX);
                    let num3 = rng.gen_range(NUM_MIN..NUM_MAX);
                    
                    tasks_generated.push(Self::SUM {
                        numbers: [num1, num2, num3],
                        result: num1+num2+num3,
                    });
                },
                2 => {
                    let x = rng.gen_range(NUM_MIN..NUM_MAX);
                    let power = rng.gen_range(1..6);
                    let mut result = 1u64;

                    while (result+1).pow(power as u32) <= x {
                        result+=1;
                    }

                    tasks_generated.push(Self::XK {
                        x,
                        power,
                        result,
                    });
                },
                3 => {
                    let target = format!("{}", rng.gen_range(NUM_MIN..NUM_MAX));
                    let del = target.chars().choose(&mut rng).unwrap();
                    let result = target.replace(del, "");

                    tasks_generated.push(Self::StringDeletion {
                        target,
                        del,
                        result,
                    });
                },
                4 => {
                    let target = format!("{}", rng.gen_range(NUM_MIN..NUM_MAX));
                    let result = format!("{}{}", target, target);

                    tasks_generated.push(Self::StringConcat {
                        target,
                        result,
                    });
                },
                _ => {}
            }
        }

        tasks_generated
    }
/// Generates a vector of tasks based on a given seed
///
/// # Arguments
/// * `seed` - A number used for pseudo random number generation
///
Generates a vector of tasks based on a given seed
Generates a vector of tasks based on a given seed
pub fn gen_tasks(seed: u64) -> Vec<Self> {
        if TASKS_AMOUNT > 5 {
            panic!("There is only 5 tasks. Cannot generate more than that!");
        }
        let mut tasks_given = Vec::<u8>::new();
        let mut rng = Pcg64::seed_from_u64(seed);
        for _ in 0..TASKS_AMOUNT {
            // ToDo: replace the task assignment with something more optimal
            let mut id = rng.gen_range(0..5);
            while tasks_given.contains(&id) {
                id = rng.gen_range(0..5);
            }
            tasks_given.push(id);
        }
        let mut tasks_generated = Vec::<Self>::new();
        for task_id in tasks_given {
            match task_id {
                0 => {
                    let amount: u8 = rng.gen_range(2..6);
                    let mut numbers = Vec::new();
                    let mut result = 0;
                    for _ in 0..amount {
                        let number = rng.gen_range(NUM_MIN..NUM_MAX);
                        result = gcd(result, number);
                        numbers.push(number);
                    }
                    tasks_generated.push(Self::GCD {
                        numbers,
                        result,
                    });
                },
                1 => {
                    let num1 = rng.gen_range(NUM_MIN..NUM_MAX);
                    let num2 = rng.gen_range(NUM_MIN..NUM_MAX);
                    let num3 = rng.gen_range(NUM_MIN..NUM_MAX);
                    tasks_generated.push(Self::SUM {
                        numbers: [num1, num2, num3],
                        result: num1+num2+num3,
                    });
                },
                2 => {
                    let x = rng.gen_range(NUM_MIN..NUM_MAX);
                    let power = rng.gen_range(1..6);
                    let mut result = 1u64;
                    while (result+1).pow(power as u32) <= x {
                        result+=1;
                    }
                    tasks_generated.push(Self::XK {
                        x,
                        power,
                        result,
                    });
                },
                3 => {
                    let target = format!("{}", rng.gen_range(NUM_MIN..NUM_MAX));
                    let del = target.chars().choose(&mut rng).unwrap();
                    let result = target.replace(del, "");
                    tasks_generated.push(Self::StringDeletion {
                        target,
                        del,
                        result,
                    });
                },
                4 => {
                    let target = format!("{}", rng.gen_range(NUM_MIN..NUM_MAX));
                    let result = format!("{}{}", target, target);
                    tasks_generated.push(Self::StringConcat {
                        target,
                        result,
                    });
                },
                _ => {}
            }
        }
        tasks_generated
    }
pub fn gen_tasks ( seed : u64 ) -> Vec < Self > { if TASKS_AMOUNT > 5 { panic ! ( " " ) ; } let mut tasks_given = Vec :: < u8 > :: new ( ) ; let mut rng = Pcg64 :: seed_from_u64 ( seed ) ; for _ in 0 .. TASKS_AMOUNT { // ToDo: replace the task assignment with something more optimal let mut id = rng . gen_range ( 0 .. 5 ) ; while tasks_given . contains ( & id ) { id = rng . gen_range ( 0 .. 5 ) ; } tasks_given . push ( id ) ; } let mut tasks_generated = Vec :: < Self > :: new ( ) ; for task_id in tasks_given { match task_id { 0 => { let amount : u8 = rng . gen_range ( 2 .. 6 ) ; let mut numbers = Vec :: new ( ) ; let mut result = 0 ; for _ in 0 .. amount { let number = rng . gen_range ( NUM_MIN .. NUM_MAX ) ; result = gcd ( result , number ) ; numbers . push ( number ) ; } tasks_generated . push ( Self :: GCD { numbers , result , } ) ; } , 1 => { let num1 = rng . gen_range ( NUM_MIN .. NUM_MAX ) ; let num2 = rng . gen_range ( NUM_MIN .. NUM_MAX ) ; let num3 = rng . gen_range ( NUM_MIN .. NUM_MAX ) ; tasks_generated . push ( Self :: SUM { numbers : [ num1 , num2 , num3 ] , result : num1 + num2 + num3 , } ) ; } , 2 => { let x = rng . gen_range ( NUM_MIN .. NUM_MAX ) ; let power = rng . gen_range ( 1 .. 6 ) ; let mut result = 1u64 ; while ( result + 1 ) . pow ( power as u32 ) <= x { result += 1 ; } tasks_generated . push ( Self :: XK { x , power , result , } ) ; } , 3 => { let target = format ! ( " " rng gen_range ( NUM_MIN NUM_MAX ) ) ; let del = target . chars ( ) . choose ( & mut rng ) . unwrap ( ) ; let result = target . replace ( del , " " ) ; tasks_generated . push ( Self :: StringDeletion { target , del , result , } ) ; } , 4 => { let target = format ! ( " " rng gen_range ( NUM_MIN NUM_MAX ) ) ; let result = format ! ( " " target target ) ; tasks_generated . push ( Self :: StringConcat { target , result , } ) ; } , _ => { } } } tasks_generated }
Generates a vector of tasks based on a given seed
Generates a vector of tasks based on a given seed
seed
u64