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
# Rock Paper Scissors is a usual game | |
class Opponent | |
def initialize | |
@rps = ['rock', 'paper', 'scissors'] | |
end | |
def play | |
@rps[rand 3] | |
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
t = Time.now | |
dayth = t.yday | |
last_digit = dayth.to_s.slice(-1, 1).to_i | |
def ordinal(last_digit) | |
case last_digit | |
when 1 | |
"st" | |
when 2 | |
"nd" |
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 Binary_heap | |
def initialize(num = 10) | |
@ary = Array.new | |
num.times do @ary << rand(100) end | |
end | |
attr_reader :items, :ary | |
def binary_heap() | |
@ary.unshift(nil) |
NewerOlder