Skip to content

Instantly share code, notes, and snippets.

@adeng21
adeng21 / Hashes in Array
Created February 22, 2014 13:39
Compound Data Structures Challenge
favorite_movies = [
{title: 'The Big Lebowski', year_released: 1998, director: 'Joel Coen', imdb_ratings: 8.2},
{title: 'The Shining', year_released: 1980, director: 'Stanley Kubrick', imdb_ratings: 8.5},
{title: 'Troll 2', year_released: 1990, director: 'Claudio Fragasso', imdb_ratings: 2.5}
]
favorite_movies.each do |movie|
puts "#{movie[:year_released]}: #{movie[:title]}"
end
@adeng21
adeng21 / Simple Hash Iteration
Created February 22, 2014 13:08
Ruby Data Structures Challenge 1
characters = {
"Tyrion Lannister" => "House Lannister",
"Jon Snow" => "Night's Watch",
"Hodor" => "House Stark",
"Stannis Baratheon" => "House Baratheon",
"Theon Greyjoy" => "House Greyjoy"
}
characters.each do |char|
puts "#{char[0]} represents the #{char[1]}"
@adeng21
adeng21 / Shopping List Git Log
Created February 21, 2014 13:28
SCM Challenge 1
commit 370f99e689724371493ff64b3f7bd078b97e460a
Author: adeng21 <[email protected]>
Date: Thu Feb 20 18:54:54 2014 -0500
made another minor change to test git
commit 954b8edc3ab52a9e38aff268e4d59188646ed000
Author: adeng21 <[email protected]>
Date: Thu Feb 20 18:53:30 2014 -0500
@adeng21
adeng21 / Cash Register Challenge #2
Created February 19, 2014 17:05
Cash Register Challenge #2
total = []
while true do
puts "What is the sale price?"
input = gets.chomp
if input == 'done'
break
else
total << input.to_f
@adeng21
adeng21 / guess the number game
Created February 18, 2014 22:26
Guess the Number Game
puts "Guess a number between 0 and 1000"
guess = gets.chomp.to_i
number=273
if guess > 273 && guess <= 1000
puts "Too high. Try a lower number"
elsif guess < 273 && guess >= 0
puts "Too low! Try again"
elsif guess > 1000 || guess < 0
puts "Invalid number. Try again - any number between 0 and 1000"
else guess == 273
@adeng21
adeng21 / Cash_Register_1
Created February 18, 2014 19:19
Cash Register Challenge 1
puts "What is the amount due?"
total = gets.chomp.to_f
puts "What is the amount tendered?"
paid = gets.chomp.to_f
if paid < total
puts "WARNING: Customer still owes $#{format("%.2f", total-paid)}"
puts Time.now
elsif paid > total