Bruteforce Rust
\n# Complexity\n- Time complexity:O(n^2)\n Add your time complexity here, e.g. O(n) \n\n\n# Code\nrust []\n\nimpl Solution {\n    pub fn count_pairs(nums: Vec<i
\n# Complexity\n- Time complexity:$$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```rust []\n\nimpl Solution {\n    pub fn count_pairs(nums: Vec<i32>) -> i32 {\n        fn check(mut a:i32,mut b:i32)-> bool {\n            if (a == b) {return true;}\n            let mut flag = 0;\n            let mut flaga = -1;\n            let mut flagb = -1;\n            let mut flagc = -1;\n            let mut flagd = -1;\n            let mut flage = -1;\n            let mut flagf = -1;\n            let mut flagg = -1;\n            let mut flagh = -1;\n            while !(a == 0 && b == 0){\n                if a %10 == b%10{\n                    \n                }else{\n                    if flag == 1{\n                        flagc = a %10;\n                        flagd = b%10;\n                        flag = 2;\n                        \n                    }else if flag == 4{\n                        return false;\n                    }else if flag == 3{\n                        flagg = a %10;\n                        flagh = b%10;\n                        flag = 4;\n                    }else if flag == 2{\n                        flage = a %10;\n                        flagf = b%10;\n                        flag = 3;\n                    }else if flag == 0{\n                        flaga = a %10;\n                        flagb = b%10;\n                        flag = 1;\n                    }else{\n                        return false;\n                    }\n                }\n                a = a/10;\n                b = b/10;\n            }\n            \n            if (flag == 2){\n                return (flaga == flagd && flagb== flagc);\n            }else if (flag == 3){\n                return (flaga == flagd && flagb== flage && flagf == flagc)||(flaga == flagf && flagb== flagc && flage == flagd );\n                \n            }else{\n                //a c e g\n                //b d f h\n                return (flaga == flagd && flagb== flagc && flage == flagh && flagg== flagf)||(flaga == flagf && flagb== flage && flagc == flagh && flagg== flagd)||(flaga == flagh && flagb== flagg && flagc == flagf && flagd== flage);\n            }\n                \n        }\n        let mut ans = 0;\n        for i in 0..nums.len(){\n            for j in i+1..nums.len(){\n                if check(nums[i] ,nums[j]){\n                    ans += 1;\n                }\n            }\n        }\n        ans\n    }\n}\n```
['Rust']