Skip to content

Instantly share code, notes, and snippets.

View montekaka's full-sized avatar

Josh Chen montekaka

View GitHub Profile
@montekaka
montekaka / 26.rb
Created November 28, 2016 21:27
26 created by montekaka - https://repl.it/E90n/37
def reciprocal_cycles(numerator, num_of_denominators)
max_length = 0
answer = 0
i = 2
while i <= num_of_denominators
p "1/#{i} has #{division(numerator, i)}"
if division(numerator, i) > max_length
max_length = division(numerator, i)
answer = i
end
# Write a function word_unscrambler that takes two inputs: a scrambled
# word and a dictionary of real words. Your program must then output
# all words that our scrambled word can unscramble to.
#
# Hint: To see if a string `s1` is an anagram of `s2`, split both
# strings into arrays of letters. Sort the two arrays. If they are
# equal, then they are anagrams.
#
# Difficulty: 3/5
# Write a function, `rec_intersection(rect1, rect2)` and returns the
# intersection of the two.
#
# Rectangles are represented as a pair of coordinate-pairs: the
# bottom-left and top-right coordinates (given in `[x, y]` notation).
#
# Hint: You can calculate the left-most x coordinate of the
# intersection by taking the maximum of the left-most x coordinate of
# each rectangle. Likewise, you can calculate the top-most y
# coordinate of the intersection by taking the minimum of the top most