Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Change the module04::ex03 and swap module04::ex03 with module04::ex04 #37

Open
JonathanDUFOUR opened this issue Oct 20, 2023 · 0 comments
Assignees
Labels
Enhancement Something already existing that could be improved or rework for the better

Comments

@JonathanDUFOUR
Copy link
Collaborator

In order to make it more interesting to use previously implemented iterators, I suggest that we re-make the module04::ex03.
The current exercise wants us to implement an iterator to generate a Fibonacci sequence, allowing us to choose manually the first terms of the sequence, but the additional function to implement is not well designed to either force or strongly encourage us to use the iterators we previously implemented. Thus, I suggest a new exercise, that would want us to implement an iterator to find the next prime number, starting at 0, and after that, as an additional function, it could ask us to implement the following function:

fn prime_decomposition(n: u32) -> Vec<(u32, u8)>;

that have to decompose the given number n into a Vec of [u32; u8] where the first element will be the prime factor value, and the second element will be the prime factor power.

For example:

assert_eq!(
    prime_decomposition(0),
    vec![],
);
assert_eq!(
    prime_decomposition(1),
    vec![],
);
assert_eq!(
    prime_decomposition(42),
    vec![
        (2, 1),
        (3, 1),
        (7, 1),
    ],
);
assert_eq!(
    prime_decomposition(72000),
    vec![
        (2, 6),
        (3, 2),
        (5, 3),
    ],
);

Also, if this new exercise is accepted, I suggest that we interchange the module04::ex03 and the module04::ex04 because of the difficulty of this new exercise, and because the current module04::ex04 seems easier, so to preserve the increasing difficulty along the entire module, we should swap them.

@JonathanDUFOUR JonathanDUFOUR added the Enhancement Something already existing that could be improved or rework for the better label Oct 20, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Enhancement Something already existing that could be improved or rework for the better
Projects
None yet
Development

No branches or pull requests

2 participants