rust-practice / cargo-leet

Program to make working on leetcode problems locally more convenient
Apache License 2.0
5 stars 3 forks source link

Handle assertion for Vec<f64> #33

Closed sak96 closed 1 year ago

sak96 commented 1 year ago
else if  Some(FunctionArgType::VecF64) = &self.return_type {
            r#"
            assert!(actual.len(), expected.len(), "actual {actual} not same length as {expected}");
            actual.iter().zip(expected.iter()).enumerate().for_each(|(i, (actual, expected))| {
            assert!((actual - expected).abs() < 1e-5, "Assertion failed: {i}th element in actual {actual:.5} but expected {expected:.5}. Diff is more than 1e-5.");
           })
            "#
} else

use match statement if it helps

c-git commented 1 year ago

Yeah I think it would make sense to change to a match statement instead. Do any problems use this return type?

c-git commented 1 year ago

I did a Ctrl + F on my repo and found one https://leetcode.com/problems/evaluate-division/