This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def valid_brackets?(brackets_string) | |
| stack = [] | |
| matcher = { ')' => '(', '}' => '{' } | |
| brackets_string.chars.each do |el| | |
| if matcher.values.include? el | |
| stack.push el | |
| elsif stack.last == matcher[el] | |
| stack.pop | |
| else | |
| return false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'byebug' | |
| require 'wrong/assert' | |
| require "benchmark/ips" | |
| include Wrong::Assert | |
| module Search | |
| def get_bit(num, bit = 1) | |
| unless num & bit == 0 | |
| return bit | |
| else |