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
#all classes in one file to fit whole code in one gist file | |
class Match | |
attr_accessor :goal_balls, :missed_balls | |
def initialize | |
@goal_balls = rand(10) | |
@missed_balls = rand(10) | |
end | |
def won_match? | |
true if goal_balls - missed_balls > 1 |
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
#all classes in one file to fit whole code in one gist file | |
#В одном массиве записан рост некоторых студентов, а в другом (с тем же числом элементов) - | |
#их фамилии в том же порядке, в котором указан рост. Известно, что все студенты разного роста. | |
#апечатайте фамилию самого высокого студента. | |
class Student | |
attr_reader :last_name, :height | |
def initialize(last_name, height) | |
@height = height | |
@last_name = last_name |
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
def make_output(array) | |
40.times { print "-"} | |
puts "\n#{array.join(", ")}" | |
end | |
def generate_array | |
array = [] | |
rand(10..20).times { array << rand(-10..10)} | |
array | |
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
def generate_array(size) | |
array = [] | |
size.to_i.times { array << rand(-10..20) } | |
array | |
end | |
#have some questions accroding to this task (probably, it can be done with 'each'?!) | |
def insert_zeros_to_array(array) | |
i = 0 | |
while(i < array.size) do | |
if array[i] > 0 |
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
array = [] | |
rand(20..30).times { array << rand(0..40)} | |
puts "Original array #{ array.join(" ") }" | |
puts "Result array #{ array.sort.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
def make_output(array) | |
50.times { print "-" } | |
puts | |
puts array.join(" - ") | |
puts "" | |
end | |
def generate_array(size) | |
array = [] | |
size.to_i.times { array << rand(10..30) } |
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
array_of_words = ["Words", "Sobaka", "Paralelogram", "Polundrom", "Yes", "No"] | |
puts array_of_words.sort_by { |word| word.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
def find_words_number(string) | |
string.split.size | |
end | |
puts "Enter Your string:" | |
string = gets.chomp | |
puts "Words Number ---> #{find_words_number(string)}" |
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
#it's not very good to do that... | |
class String | |
def palindrome? | |
self == self.reverse | |
end | |
end | |
input = gets.chomp | |
puts input.palindrome? ? true : false |
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 EducationGarfieldParser < Scripting::CustomParser | |
@@document | |
@@base_prod | |
@@ctx | |
# def initialize | |
# | |
# end | |
def parse(ctx) |
OlderNewer