# Puzzle: Valid Braces \[algorithms\]

**URL:** <https://forum.codeselfstudy.com/t/puzzle-valid-braces-algorithms/2488>\
**Category:** Puzzles and Logic\
**Created:** [November 9, 2020, 11:38pm UTC](https://forum.codeselfstudy.com/t/puzzle-valid-braces-algorithms/2488 "2020-11-09T23:38:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![content\_bot](https://forum.codeselfstudy.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@content\_bot](https://forum.codeselfstudy.com/u/content_bot)\
**Post date:** [November 9, 2020, 11:38pm UTC](https://forum.codeselfstudy.com/t/puzzle-valid-braces-algorithms/2488/1 "2020-11-09T23:38:57Z")

</div>

“ **Valid Braces** ” is a coding puzzle that people can be attempted in the following languages: javascript, coffeescript, haskell, csharp, python, java, ruby, php, typescript, elixir, cpp, dart, rust, swift, go, lua, and scala.

- **Difficulty:** 6 kyu
- **Stars:** 1510
- **Votes:** 3498
- **Category:** algorithms
- **Tags:** Algorithms, Validation, Logic, Utilities
- **Source:** [codewars](https://www.codewars.com/kata/5277c8a221e209d3f6000b56)

# Description

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.

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!

All input strings will be nonempty, and will only consist of parentheses, brackets and curly braces: `()[]{}`.

### What is considered Valid?

A string of braces is considered valid if all braces are matched with the correct brace.

## Examples

```auto

"(){}[]" =&gt; True
"([{}])" =&gt; True
"(}" =&gt; False
"[(])" =&gt; False
"[({})](]" =&gt; False

```

# Solve It Here

Click the link below to solve it on Codewars:

> **[Valid Braces](https://www.codewars.com/kata/5277c8a221e209d3f6000b56)**
>
> 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. 
> This Kata is similar t...

# Notes

This puzzle was posted by a Slackbot via a slash command. If you want to help work on the app, send a message to @Josh.

If you don’t want to see the coding puzzles when you visit the forum, you can go into [your settings](https://forum.codeselfstudy.com/my/preferences/categories) and mute the puzzles category.

---

<div class="post-metadata">

**Author:** ![Josh](https://forum.codeselfstudy.com/user_avatar/forum.codeselfstudy.com/josh/32/4_2.png) [@Josh](https://forum.codeselfstudy.com/u/Josh)\
**Post date:** [November 11, 2020, 9:33am UTC](https://forum.codeselfstudy.com/t/puzzle-valid-braces-algorithms/2488/2 "2020-11-11T09:33:12Z")

</div>

I did this one in Elixir. The #1 upvoted solution in Elixir was pretty interesting because of the way it used pattern matching.
