Skip to content

Commit aeb7106

Browse files
committed
Add ruby solution for balanced brackets problem, fix minor grammar error in CONTRIBUTING.md
1 parent cf75123 commit aeb7106

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ To add a new problem to the repo, no solution needs to be present. Just add a fo
88

99
### Adding a new solution
1010

11-
To add a new solution to the repo, add the solution to the correct language directory in the solutions directory. Make the solution file name match the the problem. If a solution already exists, but your solution is distinctly different to the current solution, place both solutions in a directory named after the problem. The file names should then accurately represent the type of solution used in each solution. If you must use multiple files for your solution, create a solution directory and another directory for your solution assets.
11+
To add a new solution to the repo, add the solution to the correct language directory in the solutions directory. Make the solution file name match the problem. If a solution already exists, but your solution is distinctly different to the current solution, place both solutions in a directory named after the problem. The file names should then accurately represent the type of solution used in each solution. If you must use multiple files for your solution, create a solution directory and another directory for your solution assets.
1212

1313
## Style Guide
1414

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def balanced_brackets(str)
2+
brackets = { '(' => ')', '{' => '}', '[' => ']' }
3+
4+
arr = []
5+
str.each_char do |c|
6+
if brackets[c] then arr << c
7+
else return false if arr.size < 1 || (brackets.key(c) != arr.pop) end
8+
end
9+
arr.size == 0 ? true : false
10+
end

0 commit comments

Comments
 (0)