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
# load into test setup after `require 'capybara/rails'` | |
# some sources for below flags and profile settings | |
# https://stackoverflow.com/questions/43143014/chrome-is-being-controlled-by-automated-test-software/43145088 | |
# https://sqa.stackexchange.com/questions/26051/chrome-driver-2-28-chrome-is-being-controlled-by-automated-test-software-notif | |
# http://stackoverflow.com/questions/12211781/how-to-maximize-window-in-chrome-using-webdriver-python | |
# update sources for new Options object | |
# https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings | |
# https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/driver.rb | |
begin |
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
# В одном массиве записано количество мячей, забитых футбольной командой в каждой из 20 игр, | |
# в другом - количество пропущенных мячей в этой же игре. | |
# Для каждой игры определите словесный результат игры (выигрыш, проигрыш или ничью). | |
goal_scored = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] | |
missed_balls = [4, 1, 2, 4, 5, 5, 8, 12, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5] | |
goal_scored.zip(missed_balls) do |goal, miss| | |
if goal > miss | |
puts "Victory :)" |
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
class Game | |
attr_reader :won_balls | |
attr_reader :missed_balls | |
def initialize(won_balls, missed_balls) | |
@won_balls = won_balls | |
@missed_balls = missed_balls | |
end | |
def result |
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
#gets the index of the biggest height and | |
#extracts the surname at this index | |
def get_surname_of_tallest(height_arr, surname_arr) | |
tallest_index = height_arr.index(height_arr.max) | |
surname_arr[tallest_index] | |
end | |
puts "Enter the heights of students" | |
heights = gets.chomp.split.map(&:to_i) |
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
puts "Enter the elements of array: (f.e. 1 2 3 4)" | |
arr = gets.chomp.split.map(&:to_i) | |
#if the element is positive it is replaced with the smallest element | |
#otherwise it remains untouched | |
min_element = arr.min | |
arr.collect! {|x| x > 0 ? min_element : x } | |
puts "The result array: #{arr.join(" ")}" |
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
puts "Enter the elements of array: (f.e. 1 2 3 4)" | |
arr = gets.chomp.split.map(&:to_i) | |
#extracting the first element in array | |
#pushing it to the last place | |
arr.push(arr.shift) | |
puts "The result array: #{arr.join(" ")}" |
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
puts "Enter the elements of array: (f.e. 1 2 3 4)" | |
arr = gets.chomp.split.map(&:to_i) | |
#inserting the special value | |
#before every positive element | |
arr.map!{ |el| el > 0 ? [0, el] : el } | |
arr.flatten! | |
puts "The result array: #{arr.join(" ")}" |
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
puts "Enter the elements of array: (f.e. 1 2 3 4)" | |
arr = gets.chomp.split.map(&:to_i) | |
#sort ascending | |
arr.sort! | |
puts "The result array: #{arr.join(" ")}" |
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
puts "Enter the string:" | |
arr = gets.chomp.split | |
#sorting words by letters count | |
str = arr.sort_by(&:length).join(" ") | |
puts "The result string: #{str}" |
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
puts "Enter the string:" | |
arr = gets.chomp.split | |
#getting the number of words in string | |
puts "The words count: #{arr.count}" |
OlderNewer