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 "serverspec" | |
require "docker" | |
package = ['rake', 'pg'] | |
describe "Dockerfile" do | |
before(:all) do | |
@image = Docker::Image.build_from_dir('.', {'dockerfile'=>'Dockerfile'}) | |
@image.tag(repo: 'image-test', tag: 'latest'). |
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
arr = [9,81,-9,3,0,12,-10] | |
def find_min(list) | |
min = list[0] | |
index = 0 | |
list.each_with_index do |val, i| | |
if val < min | |
min = val | |
index = i | |
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
graph = {} | |
graph['start'] = Hash.new | |
graph['start']['a'] = 6 | |
graph['start']['b'] = 2 | |
graph['a'] = Hash.new | |
graph['a']['fin'] = 1 | |
graph['b'] = Hash.new | |
graph['b']['a'] = 3 | |
graph['b']['fin'] = 5 |
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 sum_digits digit | |
if digit < 10 | |
digit | |
else | |
(digit % 10) + (digit / 10).to_f | |
end | |
end | |
def validate number | |
number = number.to_s.reverse.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
# Set cover problem | |
states = ['mt', 'wa', 'or', 'id', 'nv', 'ut', 'ca', 'az'].uniq | |
station = {} | |
station["kone"] = ['id', 'nv', 'ut'].uniq | |
station["ktwo"] = ['mt', 'wa', 'id'].uniq | |
station["kthree"] = ['or', 'nv', 'ca'].uniq | |
station["kfour"] = ['nv', 'ut'].uniq | |
station["kfive"] = ['ca', 'az'].uniq |
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 fib_rec (number) | |
if number == 0 | |
return number | |
elsif (number == 1) || (number == 2) | |
return 1 | |
end | |
fib_rec(number - 1) + fib_rec(number - 2) | |
end | |
def fib_non_rec (number) |
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
package main | |
import "fmt" | |
var mes = "test cypeher with digit 6" | |
func main() { | |
bs := ([]byte)(mes) | |
cyp := make([]byte, len(bs)) | |
j := 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
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
a := 32 | |
b := -44 |
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
fib = 9 | |
def BinetFib number | |
phi = ((1 + Math.sqrt(5)) / 2) #or 1.6180339887 | |
divid = phi**number | |
divider = Math.sqrt(5) | |
(divid / divider).round | |
end | |
puts BinetFib(fib); |
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
digit = 543210 | |
# Reverse digit | |
def reverse_digit(digit) | |
str = digit.to_s.reverse.split('') | |
if str.first == '0' | |
str.shift | |
end | |
str.join('').to_i | |
end |