Codewars: Rust workspace for solving the 'Valid Braces' kata
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
765 B

3 years ago
  1. ## Valid Braces
  2. Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return `true` if the string is valid, and `false` if it's invalid.
  3. This Kata is similar to the [Valid Parentheses](https://www.codewars.com/kata/valid-parentheses) Kata, but introduces new characters: brackets `[]`, and curly braces `{}`. Thanks to `@arnedag` for the idea!
  4. All input strings will be nonempty, and will only consist of parentheses, brackets and curly braces: `()[]{}`.
  5. **What is considered Valid?**
  6. A string of braces is considered valid if all braces are matched with the correct brace.
  7. **Examples**
  8. ```rust
  9. "(){}[]" => True
  10. "([{}])" => True
  11. "(}" => False
  12. "[(])" => False
  13. "[({})](]" => False
  14. ```