I hereby claim:
- I am parksilk on github.
- I am park (https://keybase.io/park) on keybase.
- I have a public key whose fingerprint is 9F45 F156 4C1A 5BD3 473D 574D 71E7 F6AC EE3A 6A4C
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
class GuessingGame | |
def initialize(answer) | |
@answer = answer | |
end | |
def guess(num_guess) | |
if num_guess > @answer then @result = :high | |
elsif num_guess < @answer then @result = :low | |
else @result = :correct | |
end |
def super_fizzbuzz(array) | |
result = [] | |
array.each do |i| | |
if i % 15 == 0 | |
result << "FizzBuzz" | |
elsif i % 5 == 0 | |
result << "Buzz" | |
elsif i % 3 == 0 | |
result << "Fizz" | |
else |
def times_table(rows) | |
1.upto(rows) do |r| | |
1.upto(rows) do |c| | |
print (r * c), "\t" # the "\t" tabbs over and creates better colums than spaces | |
end | |
print "\n" | |
end | |
end | |
# it's two loops and the variables that track the number of iteratinos (r and c) |
def mode(array) | |
counter = Hash.new(0) | |
# this creates a new, empty hash with no keys, but makes all defalt values zero. it will be used to store | |
# the information from the array, such that the keys will be each unique number from the array (IOW, if there | |
# are two or more 4's in the array, there will just be one key that is a 4), and the value for each key will | |
# be the number of times that integer appears in the array. | |
array.each do |i| | |
counter[i] += 1 | |
end | |
# this interates throught the array, and for each element it creates a key for that integer (if it hasn't been |
def valid_triangle?(a, b, c) | |
if a+b>c and a+c>b and b+c>a | |
true | |
else | |
false | |
end | |
end |