This file contains 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
# 1) В одном массиве записано количество мячей, забитых футбольной командой в каждой из 20 игр, | |
# в другом - количество пропущенных мячей в этой же игре. Для каждой игры определите | |
# словесный результат игры (выигрыш, проигрыш или ничью). (edited) | |
class GameStatisticAttraction | |
def perform | |
goal = Array.new(20){rand(1...10)} | |
miss = Array.new(20){rand(1...10)} | |
game = Hash[goal.zip(miss)] |
This file contains 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
# 2) В одном массиве записан рост некоторых студентов, а в другом | |
# (с тем же числом элементов) - их фамилии в том же порядке, в котором указан рост. | |
# Известно, что все студенты разного роста. Напечатайте фамилию самого высокого студента. | |
def perform | |
growth = Array.new(6){rand(150..200)} | |
surname = ["Anderson", "Ashwoon", "Aikin", "Bateman", "Bongard", "Bowers"] | |
group = surname.zip(growth) | |
group_h = Hash[group] |
This file contains 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
# 3) Дан целочисленный массив. Заменить все положительные элементы на значение минимального. | |
class Max2MinArrayElement | |
# Условие описано не ясно. Минимальных елементов здесь 2: | |
# Минимальное отрицательное | |
# Минимальное положительное | |
def initialize | |
@the_greatest_array = Array.new(15){rand(-100...100)} | |
end | |
# Решение первое. При минимальном отрицательном | |
def negative_change |
This file contains 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
# 4) Дан целочисленный массив. Осуществить циклический сдвиг элементов массива | |
# влево на одну позицию. | |
class ShakingArrayLeft | |
def initialize | |
@not_so_greatest_array = Array.new(7){rand(-100...100)} | |
end | |
def shake_2_left | |
primary_element = @not_so_greatest_array[0] | |
@not_so_greatest_array.each_with_index do |element, index| | |
if index + 1 < @not_so_greatest_array.length |
This file contains 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
# 6) Дан целочисленный массив. Упорядочить его по возрастанию. | |
def array_sort | |
victim_array = Array.new(15){rand(-100...100)} | |
victim_array.sort! | |
end |
This file contains 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
# 7) Дана строка в которой записаны слова через пробел. Необходимо упорядочить | |
# слова по количеству букв в каждом слове. | |
def sort_string_by_words_length | |
string = "alskdfj asd;lfjk asdkfj;lasd flaskdj f as;dlfjk a;sd fkla sdf;" | |
splitted = string.split | |
splitted.sort_by(&:length) | |
end |
This file contains 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
# 8) Дана строка в которой записаны слова через пробел. Необходимо посчитать | |
# количество слов. | |
def word_counter | |
string = "alskdfj asd;lfjk asdkfj;lasd flaskdj f as;dlfjk a;sd fkla sdf;" | |
string.split.size | |
end |
This file contains 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
# 9) Дана строка. Необходимо проверить, является ли она палиндромом. | |
class PalindromeChecker | |
def palindrome_check | |
string = "Never a foot too far, even" | |
palindrome?(string) | |
end | |
def palindrome?(str) | |
str == str.reverse | |
end |
This file contains 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
sudo apt update | |
sudo apt install build-essential | |
wget https://nginx.org/download/nginx-1.17.4.tar.gz | |
tar -xzvf nginx-1.17.4.tar.gz | |
cd nginx-1.17.4 |
This file contains 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
brew tap homebrew/versions | |
# Error: homebrew/versions was deprecated. This tap is now empty as all its formulae were migrated. | |
# https://github.com/mrirecon/homebrew-bart/issues/1 | |
brew unlink v8 | |
brew link --force v8-315 | |
gem install therubyracer -v '0.12.2' -- --with-system-v8 |
OlderNewer