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
print "enter a max value? " | |
max_value = gets.to_i | |
target_number = rand(1..max_value); | |
def game(max_value, target_number) | |
print "Guess a number between 1 and #{max_value}? " | |
user_input = gets.to_i | |
max = max_value; | |
target_value = target_number | |
if user_input == 0 || user_input > max |
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 | |
class Game | |
def init(word) | |
@letter_array=[] | |
@guess_array = [] | |
@guesses = [] | |
@chances = 0 | |
@target_word = word.each_char do |c| | |
@letter_array << c | |
@guess_array << '|-|' |
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
(1..100).each do |x| | |
if x % 3 == 0 && x % 5 == 0 | |
puts 'fizzBuzz' | |
elsif x % 3 == 0 | |
puts 'fizz' | |
elsif x % 5 == 0 | |
puts 'Buzz' | |
else | |
puts x | |
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" | |
} | |
characters.each do |key, value| | |
puts "#{key} represents the #{value}" |
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_array = [75, 100, 85, 65, 84, 87, 95] | |
puts "the lowest score is: #{score_array.sort![0]}" | |
puts "the Highest score is: #{score_array.last}" | |
def average(scores,length) | |
sum = 0 | |
scores.each do |x| | |
sum += x | |
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
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]}: Title: #{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
train={ 'Train 1' => 2, 'Train 2' => 5, 'Train 3' => 7.5, 'Train 4' => 8.5, 'Train 5' => 9, 'Train 6' => 10, 'Train 7' => 11.5, 'Train 8' => 13.5, 'Train 9' => 14.5, 'Train 10' => 17, 'Train 11' => 18,'Train 12' => 19, 'Train 13' => 24 } | |
print "what time do you want to leave: " | |
user_input = gets.chomp.to_f | |
def midnight_print | |
lyrics = "Just a small town girl Livin' in a lonely world She took the midnight train | |
Goin' anywhere |
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 | |
require 'csv' | |
balance = 0.00 | |
sum_income = 0.00 | |
sum_deduction = 0.00 | |
overdrafts=[] | |
deposits = [] |
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 | |
# encoding: UTF-8 | |
class Blackjack | |
SUITS = ['♠', '♣', '♥', '♦'] | |
VALUES = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] | |
def initialize | |
@deck = [] | |
@player=[] |
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 | |
if rank.nil? | |
@rank = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'].sample | |
else |
OlderNewer