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
require "faker" [35/39] | |
class RecursiveCocktail | |
def initialize(ingredients: {}, capacity: 500) # default capacity - 500 ml | |
validate_ingredients!(ingredients) | |
@ingredients = {} | |
ingredients.each do |ingredient, percentage| | |
@ingredients[ingredient] = { percentage: percentage / 100.0, used: 0 } | |
end | |
@cocktail_name = generate_cocktail_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
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory |
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 solution(arr) | |
index = 0 | |
while index < arr.count do | |
left_s = (index-1) >= 0 ? arr.slice(0..(index-1)).reduce(0, :+) : 0 | |
right_s = arr.slice((index+1)..(arr.count-1)).reduce(0, :+) | |
return index if left_s == right_s | |
index +=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
require_relative "./rover" | |
input_array = [] | |
file = ARGV[0] | |
raise "Not specified input file!" if file.to_s.empty? | |
File.open(file, "r") do |f| | |
f.each_line { |line| input_array << line } | |
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
class Shutdown | |
def initialize(*options) | |
@action = options[0] | |
@time = options[1] | |
@allow_actions = %w(halt reboot) | |
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
class Shutdown | |
def initialize(arguments) | |
@argv1 = arguments[0].to_s | |
if arguments.size > 1 | |
@argv2 = arguments[1].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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# Author: seniorihor (12.03.2012) | |
class MyArray | |
def initialize | |
@array = [] | |
@max_positive = 0 | |
@max_minimum = 0 | |
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# Author: seniorihor (12.03.2012) | |
class MyArray | |
def initialize | |
@array = [] | |
end | |
def show_condition | |
print <<-CONDITION |
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# Aurhor: seniorihor (12.03.2012) | |
class General | |
def initialize(quantity, numbers) | |
@quantity = quantity | |
@numbers = numbers | |
@seconds = 0 | |
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
#!/usr/bin/python3.2 -tt | |
# *-* coding: utf-8 *-* | |
allow_names = ['Mila', 'Ihor', 'Stas', 'Michel', 'Bogdan'] | |
name = str(input('Enter your name: ')) | |
def birthday(name): | |
i = 0 | |
while i < len(allow_names): | |
# Check name |
NewerOlder