Skip to content

Instantly share code, notes, and snippets.

View shamritskiy3468's full-sized avatar

Dmitriy Shamritskiy shamritskiy3468

View GitHub Profile
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace Student_nagruzka
{
public abstract class FileHanlder
class Product
attr_accessor :name, :sku, :price, :regular_price, :promoname
def initialize(name, sku, price, regular_price, promoname)
@name = name
@sku = sku
@price = price
@regular_price = regular_price
@promoname = promoname
@stock = stock
end
class EducationGarfieldParser < Scripting::CustomParser
@@document
@@base_prod
@@ctx
# def initialize
#
# end
def parse(ctx)
#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
def find_words_number(string)
string.split.size
end
puts "Enter Your string:"
string = gets.chomp
puts "Words Number ---> #{find_words_number(string)}"
array_of_words = ["Words", "Sobaka", "Paralelogram", "Polundrom", "Yes", "No"]
puts array_of_words.sort_by { |word| word.length}
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) }
array = []
rand(20..30).times { array << rand(0..40)}
puts "Original array #{ array.join(" ") }"
puts "Result array #{ array.sort.join(" ") }"
@shamritskiy3468
shamritskiy3468 / task5.rb
Last active December 22, 2018 20:35
Task5
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
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