Skip to content

Instantly share code, notes, and snippets.

@taichiman
Created October 3, 2013 09:07
Show Gist options
  • Save taichiman/6807297 to your computer and use it in GitHub Desktop.
Save taichiman/6807297 to your computer and use it in GitHub Desktop.
My first remote interwiev :)
#a = *(0..10)
#a.delete((rand * 10).to_i)
#z=0
#a.each_with_index do |thing, index|
# if thing != index
# p index
# break
# end
#end
#p a
# x,y - исход матча
# a,b - ставка
def pay(x, y, a, b)
if (x == a) && (y == b)
2
elsif (((x > y) && (a > b)) || ((x < y) && (a < b)) || ((x == y) && (a == b)))
1
else
0
end
end
p pay(1, 4, 1, 4) == 2
p pay(1, 4, 2, 4) == 1
p pay(1, 4, 5, 3) == 0
p pay(2, 2, 3, 3) == 1
p pay(3, 3, 3, 3) == 2
p pay(4, 3, 1, 2) == 0
p pay(5, 3, 2, 1) == 1
class A
def self.foo(o)
o.bar
end
end
class B
def bar
"BAR"
end
end
class C
def bar
"BAR C"
end
end
p A.foo(B.new)
p A.foo(C.new)
http://ru.wikipedia.org/wiki/SOLID_(%D0%BE%D0%B1%D1%8A%D0%B5%D0%BA%D1%82%D0%BD%D0%BE-%D0%BE%D1%80%D0%B8%D0%B5%D0%BD%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5)
https://github.com/pluginaweek/state_machine
https://coderpad.io
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment