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
# Ruby Fundamentals I - CHALLENGE | |
def check_and_format(amount) | |
formatted_amount = nil | |
if amount.match(/\A[0-9]*[.][\d]{2}\z/) | |
formatted_amount = amount.to_f | |
else | |
puts "WARNING: Invalid currency detected! Exiting..." | |
abort |
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
commit 8737fb36e370f669d616a8efe339a2dd8ab9ab9d | |
Author: Helen Hood <helen.c.hood@gmail.com> | |
Date: Thu Nov 14 19:33:24 2013 -0500 | |
added README file to .gitignore | |
commit e3c01692adad0ea986bc92ddf3dcfafdcf78fbf5 | |
Author: Helen Hood <helen.c.hood@gmail.com> | |
Date: Thu Nov 14 19:25:49 2013 -0500 |
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
# Ruby Fundamentals II - CHALLENGE | |
# Cashier problem totals purchases, outputs subtotals, calculates changes, & prints receipt. | |
# METHOD DEFINITIONS | |
def gets_price | |
puts "What is the sale price?" | |
gets.chomp | |
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
# Ruby Fundamentals III - Challenge | |
# Write a program, given a hardcoded list of test scores, that reports the average score, the lowest score, and the highest score. | |
SCORES = [75, 100, 85, 65, 84, 87, 95] | |
def average(numbers) | |
numbers = numbers.each {|num| num.to_f} | |
sum = numbers.inject(0) {|total, num| total += num} | |
number_of_numbers = numbers.length.to_f |
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
#!/usr/bin/env ruby | |
# DEFINITIONS | |
def replace_letters(word, letters) | |
string = "[^" + letters.join + "]" | |
regex = Regexp.new(string) | |
new_word = word.gsub(regex, '_') | |
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
# Ruby Fundamentals III - Kata | |
# INPUT ARRAYS | |
salutations = [ | |
['Mr.', 'Mrs.'], | |
'Mrs.', | |
['Mr.', 'Mrs.'], | |
['Dr.'], | |
'Ms.' |
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
# Ruby Fundamentals III - Challenge | |
# NOTE: I worked on this with Jonah and then refactored on my own. | |
# METHOD DEFINITIONS | |
def get_input(prompt) | |
puts prompt | |
input = gets.chomp.to_f | |
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
# Ruby Fundamentals III - Non-core challenge | |
# Calculate the leaderboard in the following format (data is exaggerated, but the Patriots are on top!) | |
# The list should be sorted by number of wins. | |
# 1. Patriots 16 wins, 0 losses | |
# 2. Colts, 8 wins, 8 losses | |
# 3. Broncos, 4 wins, 12 losses | |
# 4. Steelers, 2 wins, 14 losses |
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
# User Stories Kata: The Next Train | |
# INPUT DATA | |
lyrics = "\n***DON'T STOP...BELIEVIN'!*** | |
Just a small town girl | |
Living in a lonely world | |
She took the midnight train going anywhere | |
Just a city boy |
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
# Ruby Fundamentals IV: Building Compound Data Structures Assignment | |
favorite_movies = [ | |
{ title: 'The Big Lebowski', year_released: 1998, director: 'Joel Coen', imdb_rating: 8.2 }, | |
{ title: 'The Shining', year_released: 1980, director: 'Stanley Kubrick', imdb_rating: 8.5 }, | |
{ title: 'Troll 2', year_released: 1990, directory: 'Claudio Fragasso', imdb_rating: 2.5 } | |
] | |
favorite_movies.each { |movie| puts "#{movie[:year_released]}: #{movie[:title]}" } |
OlderNewer