Skip to content

Instantly share code, notes, and snippets.

View jmoon90's full-sized avatar

John Moon jmoon90

  • New York, NY
View GitHub Profile
@jmoon90
jmoon90 / data.rb
Last active December 28, 2015 17:49
Calculates the leadership board.
team_data = [
{
home_team: "Patriots",
away_team: "Broncos",
home_score: 7,
away_score: 3
},
{
home_team: "Broncos",
away_team: "Colts",
@jmoon90
jmoon90 / train.rb
Last active December 28, 2015 20:08
alculate the user's next train based on their input of when the earliest is that they can leave. For ease of development, use a 24 hour format where 1:15PM == 13.25.
song = "***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
Born and raised in South Detroit
He took the midnight train going anywhere
A singer in a smoky room
def dollar_due(change_due)
d_due = (change_due / 1.00).to_i
puts "#{d_due} dollars"
left_overs = (change_due % 1.00).round(2)
if left_overs > 0.25
quarter_due(left_overs)
elsif left_overs > 0.10
dimes_due(left_overs)
elsif left_overs > 0.05
@jmoon90
jmoon90 / array_hash.rb
Last active December 29, 2015 00:19
Quick Challenge: Using what you know about arrays and through searching online with your review pair, write a small program for the hash supplied above that outputs the lines below. Write the program in a way where we could easily add more characters to the list and include them in the output.
characters = {
"Tyrion Lannister" => "House Lannister",
"Jon Snow" => "Night's Watch",
"Hodor" => "House Stark",
"Stannis Baratheon" => "House Baratheon",
"Theon Greyjoy" => "House Greyjoy"
}
characters.each do |name,house|
puts "#{name} represents the #{house}"
@jmoon90
jmoon90 / favorite_movie.rb
Last active December 29, 2015 00:39
Given a data set. Output the titles, along with their year
require 'pry'
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 do |movies|
puts "#{movies[:year_released]}: #{movies[:title]}"
end
@jmoon90
jmoon90 / echo_p1.rb
Last active December 29, 2015 03:39
def playback(repeat)
repeat
puts "You said: #{repeat}"
end
puts "What do you want to say?"
print "> "
playback(gets.chomp)
def playback(repeat)
if repeat == "Nothing!"
puts "Ok, fine!"
elsif repeat == "I have a lot to say"
puts " don\'t have time for that right now!"
else
puts "You said: #{repeat}"
end
require 'pry'
def playback(repeat)
if repeat == "Nothing!"
puts "Ok, fine!"
elsif repeat == "I have a lot to say"
lot_to_say
else
puts "You said: #{repeat}"
end
def playback(repeat)
if repeat == "Nothing!"
puts "Ok, fine!"
elsif repeat == "I have a lot to say"
puts "Ok, let\'s hear it!"
print "> "
lot_to_say
out_put_format(things_to_say)
elsif repeat == "I have something prepared"
puts "Ok, where can I find what you want to say?"
require 'pry'
class BlackJack
def initialize
@deck = Deck.new.build_deck
@players_hand = {}
@symbol_value = PlayingCards.new.symbols
player
@players_score = Hash.new(0)