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
class Card | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
@rank = rank |
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
require 'json' | |
require 'pry' | |
data = JSON.parse(IO.read('movies_data.json')) | |
# cast_members = data['movies'][0]['abridged_cast'] | |
# cast_member_names = cast_members.map{|member| member['name']} | |
all_cast_members = [] | |
all_cast_characters = [] | |
movies = data['movies'] |
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
require 'csv' | |
require 'pry' | |
file = 'lackp_starting_rosters.csv' | |
# Create an empty teams hash | |
teams = {} | |
# Open up the CSV and save it to the variable csv | |
csv = CSV.open(file, headers: true) |
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 RETURN VALUE DRILLS | |
# ---------------------------- | |
def is_a_number?(some_string) | |
if some_string =~ /\A\d*[.]{0,1}\d*\z/ | |
true | |
else | |
false | |
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
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
puts "Double every value in array." | |
def double(numbers) | |
numbers.each do |num| | |
puts num *=2 | |
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
numbers= [75, 100, 85, 65, 84, 87, 95] | |
def average (numbers) | |
sum=0 | |
numbers.each do |num| | |
sum += num | |
end | |
sum/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
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 |movie| | |
puts "#{movie[:year_released]}: #{movie[:title]}" | |
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
characters = { | |
"Tyrion Lannister" => "House Lannister", | |
"Jon Snow" => "Night's Watch", | |
"Hodor" => "House Stark", | |
"Stannis Baratheon" => "House Baratheon", | |
"Theon Greyjoy" => "House Greyjoy" | |
} | |
lannisters_house = characters ["Tyrion Lannister"] | |
snows_house = characters ["Jon Snow"] |
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
score_set_1 = [75, 100, 85, 65, 84, 87, 95] | |
score_set_2 = [98, 48, 67, 79, 82] | |
score_set_3 = [55, 97, 61, 83] | |
score_set_4 = [99, 71, 82, 87, 60] | |
all_score_sets = [[score_set_1], [score_set_2], [score_set_3], [score_set_4]] | |
def avg (all_score_sets) | |
avg= ((sum += all_score_sets.each)/(all_score_sets.each.length)) | |
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
#TO DO LIST OF THING THAT NEED TO BE MADE | |
#1- count function | |
#2 - make it look pretty | |
#3- make it lose | |
def update_the_user_facing_word(hidden_word, guess, user_facing_word) | |
postion_in_the_word_hidden_word = 0 | |
hidden_word.each_char do |letter| | |
#start loop |