Provider | Singleton | Instantiable | Configurable |
---|---|---|---|
Constant | Yes | No | No |
Value | Yes | No | No |
Service | Yes | No | No |
Factory | Yes | Yes | No |
Decorator | Yes | No? | No |
Provider | Yes | Yes | Yes |
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 unique_in_order(iterable) | |
(iterable.instance_of?(String) ? iterable.chars : iterable).chunk { |x| x }.map(&:first) | |
end |
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 flatten arr | |
arr.each_with_object([]) do |element, result| | |
result.push *(element.is_a? Array ? flatten(element) : element) | |
end | |
end |
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
> a = Array.new | |
=> [] | |
> a.class.ancestors | |
=> [Array, Enumerable, Object, Kernel, BasicObject] |
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 binary_search lowest, highest, m | |
mid = (lowest + highest) / 2 | |
if $arr[mid] == m | |
mid + 1 | |
elsif $arr[mid] < m | |
binary_search mid + 1, highest, m | |
else | |
binary_search lowest, mid - 1, m | |
end | |
end |
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
n, m = gets.split(" ").map(&:to_i) | |
arr = gets.split(" ").map(&:to_i) | |
index = arr.rindex(m) | |
puts index < 0 ? index : index + 1 |
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
Algorithms: | |
https://en.wikipedia.org/wiki/Pigeonhole_principle | |
--- | |
Problems I liked: | |
http://codeforces.com/contest/743/problem/B | |
--- |
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
git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)' |
NewerOlder