This repo contains 10 coding challenges solved in Ruby language
-
anagram.rb: Given a word and a list of possible anagrams, it select the correct sublist. Given "listen" and a list of candidates like "enlists" "google" "inlets" "banana" the program should return a list containing "inlets".
-
bst.rb: A menu driven program that allows us to insert and search for an integer in a Binary Search Tree.
-
change.rb: It correctly determine the fewest number of coins to be given to a customer such that the sum of the coins' value would equal the correct amount of change. An input of 15 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) or [0, 1, 1, 0, 0]. Similary an input of 40 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) and one quarter (25) or [0, 1, 1, 1, 0]
-
isomer.rb: Determines if a word or phrase is an isogram. An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter. Examples of isograms are lumberjacks, background, downstream etc. The word isograms, however, is not an isogram, because the s repeats.
-
leap.rb: Given a year as an input, it determines if the year is leap or not.
-
panagram.rb: Determines if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma, "every letter") is a sentence using every letter of the alphabet at least once. The best known English pangram is: The quick brown fox jumps over the lazy dog.
-
pythagorean_triplet.rb: A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for which, a2 + b2 = c2. For example : 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. The program finds the product abc.
-
raindrops.rb: Converts a number to a string, the contents of which depend on the number's factors. If the number has 3 as a factor, output 'Pling'. If the number has 5 as a factor, output 'Plang'. If the number has 7 as a factor, output 'Plong'. If the number does not have 3, 5, or 7 as a factor, it just passes the number's digits straight through.
-
roman: Given a integer, the program prints its corresponding roman number equivalent.
-
word_count: Given a phrase, the program counts the occurrences of each word in that phrase. For example for the input "olly olly in come free", it prints: olly: 2 in: 1 come: 1 free: 1