Ad
  • Custom User Avatar

    I should have realized this meant don't write a prime sieve, thank you though.

    Edit: yep, removed the wheel sieve and I passed in 1582ms or so

  • Custom User Avatar

    I spent an embarassingly long time on this fiddling with iterator chains and blaming the lack of Rust compiler optimisations, before I realised I didn't need a whole prime sieve and brute force (with the obvious pruning) is more than fast enough.

  • Custom User Avatar

    FWIW, this wording probably doesn't help. I wouldn't expect most folks at this level to be familiar with terminology around multisets. The sample data definitely doesn't help in that regard.

  • Custom User Avatar

    This is a bad suggestion as this question is aimed at functional programming with algebraic datatypes. In Rust the actual return types for this function are Result::Ok(u32) and Result::Err(String). Result is a useful monoid that makes error handling super simple when you combine it with pattern matching.