Skip to content

Instantly share code, notes, and snippets.


Josh Chen montekaka

View GitHub Profile
View 26.rb
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
View BrIb-438.rb
# 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
View BrIc-230.rb
# 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