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
# test for Flatstack | |
# https://github.com/fs/test-tasks/tree/master/ruby | |
# Дана последовательность: | |
# 1 | |
# 11 | |
# 21 | |
# 1211 | |
# 111221 | |
# 312211 | |
# Нужно чтобы ваша программа могла продолжить данную последовательность. Можете в реализации использовать любые библиотеки. |
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 brackets_balanced?(s) | |
brackets = [['(',')'],['[',']'],['{','}']] | |
flatten_brackets = brackets.flatten | |
close_brackets = brackets.map{|e| e[1]} | |
stack = '' | |
for i in 0..s.size do | |
stack += s[i] if flatten_brackets.include?(s[i]) | |
stack = stack[0,stack.size-2] if brackets.include? [stack[stack.size-2,1],stack[stack.size-1,1]] | |
return false if close_brackets.include? stack[stack.size-1,1] | |
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
Is a table containing identifiers and the vertex coordinates of figures. | |
P (Polygon_id int, point_id int, x float, y float) | |
Points are listed sequentially in a clockwise or counter- clockwise | |
1. It is necessary to write a function that returns the area of a selected polygon | |
2. It is necessary to write a function that returns the perimeter of the selected polygon | |
3. Check whether the point is on the specified coordinates inside the polygon |
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
select Value+CHAR(32) from Table | |
for xml path('') |
NewerOlder