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
Peggie | Bernier | (598)-885-3990 | [email protected] | |
---|---|---|---|---|
Ines | Roberts | (717)-629-5254 | [email protected] | |
Carley | Luettgen | (153)-754-3308 | [email protected] | |
Evie | Bashirian | (684)-662-7552 | [email protected] |
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
$numbers_hash = {1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five", 6 => "six", 7 => "seven", 8 => "eigth", 9 => "nine", 10 => "ten", | |
10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen", 14 => "forteen", 15 => "fifteen", 16 => "sixteen", 17 => "seventeen", | |
18 => "eighteen", 19 => "nineteen", 20 => "twenty", 30 => "thirty", 40 => "forty", 50 => "fifty", 60 => "sixty", 70 => "seventy", | |
80 => "eighty", 90 => "ninty", 100 => "hundred", 1_000 => "thousand", 1_000_000 => "million", 1_000_000_000 => "billion", | |
1_000_000_000_000 => "trillion"} | |
def ransom_below_100(number,modifier,result) | |
quotient,remainder = number.divmod(10) |
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 binary_search(num, array) | |
return -1 if !array.include?(num) | |
index = (array.length)/2 | |
index_array = [(array.length), 0] | |
until num == array[index] | |
index = (index_array[0] + index_array[1])/2 |
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
# # Determine whether a string contains a Social Security number. | |
def has_ssn?(string) | |
/\d{3}-\d{2}-\d{4}/.match(string) | |
end | |
# Return the Social Security number from a string. | |
def grab_ssn(string) | |
string[/\d{3}-\d{2}-\d{4}/] | |
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
def birthday_timestamp(yyyy,mm,dd) | |
Time.new(yyyy,mm,dd) | |
end | |
#birthday_timestamp | |
def age(yyyy,mm,dd) |
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
# actual funtion to get the prime factors | |
def prime_factors(n) | |
primes = [] | |
until n == 1 | |
primes << prime_number(n) | |
n /= primes.last | |
puts "primes_array:#{primes.inspect} | n:#{n}" | |
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
########################## | |
# => factorial iterative | |
########################## | |
def factorial_it(n) | |
return (1..n).inject(:*) | |
end | |
#puts factorial(10) |
NewerOlder