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
I know that you wanted all the code to be in the Gist, however I have several files for this game. | |
So I uploaded to a seperate repro. https://github.com/troyleach/War | |
A couple of issues that I ran into were, I couldn't find an easy way to make my deck of cards, so I made a CSV file | |
and parsed the file to make my objects. I KNOW there has to be an easier way (I purposly did NOT google this because I | |
would really like to figure it out on my own, with a little help of course) if you look in my sandbox.rb file I a few things that I am trying. Honestly I have no idea why I can't get this to work, take a look. this might be something that I would want to meet on, or have a google video chat! | |
when I loaded this file tonight I of course ran it to make sure all was good in the world of war and I think I have an issue | |
with a algorithm. I think it MIGHT have to do with I don't sort very well I plan on working on that just a bit this week. |
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
=begin | |
To find the Median in an odd collection, | |
place the numbers in value order | |
find the middle number. | |
that number will be the median | |
to find the Median in an even collection | |
need to find the middle pair of numbers, | |
then find the value that would be half way between them. | |
(adding them together and dividing by two) |
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
=begin | |
- ask user to enter as many numbers as they wish, type done, when done (make this a until loop) until...user_input == 'done' | |
- make sure all numbers were entered | |
- store user input in an array | |
- make a method called average | |
- this method will sum all the numbers (inject) in the stored array | |
- divide the sum by the arrays length | |
- return the sum | |
ONE WAY OF DOING IT - |
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
=begin | |
I AM ALSO WORKING ON A DIFFERENT SCRIPT THAT WILL TAKE A FULL DOCUMENT SOMEWHERE FROM THE NET AND SCRUB IT AND TELL US | |
THE MOST FREQUENT WORD. | |
Instructions: | |
Have the user enter 10 words, and allow for duplicate words. After the user is done, the program will tell the user which word was entered the most frequently. |
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
# Maximum Number | |
# -------------- | |
# Have a user enter 10 numbers, and have it so that the program tells you the highest of all those numbers. Catch: Don't use the max method (which does that for you.) Use the "each" method instead. | |
# Example: If the user enters: | |
# 5, 55, 66, 23, -123, 99, 4, 2, 100, 8 | |
# the program should say: |
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
# Multiply by 2 | |
# ------------- | |
# Create program that multiplies by 2 until 100,000. That is, the program should print out: | |
# 1 (MULTIPLYING BY 2 WE WILL NEVER GET ONE.. RIGHT?) | |
# 2 | |
# 4 | |
# 8 | |
# 16 |
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
# Fortune Teller | |
# -------------- | |
# Instructions: | |
# Create a fortune teller which tells fortune based on the user's favorite number. Give at least 3 possible outcomes. So along these lines, for example: If the user's favorite number is below 50, give fortune X. If the user's favorite number is between 50 and 100, give fortune Y. If the user's favorite number is above 100, give fortune Z. | |
puts "Ready to play a fun game?" | |
puts "Your going to give me your favorite number." |
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 "exclamation: " | |
exclamation = gets.chomp | |
print "adverb: " | |
adverb = gets.chomp | |
print "Noun: " | |
noun = gets.chomp | |
print "Adjective: " | |
adjective = gets.chomp | |
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 Divide | |
attr_reader :num1, :num2, :sum, :sumR | |
def initialize(num1, num2) | |
@num1 = num1 | |
@num2 = num2 | |
end | |
def division | |
sum.to_i = num1 / num2 |
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
# Fibonacci numbers are numbers that follow the pattern: | |
# 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, etc. | |
# first 100 | |
class Fibonacci | |
attr_reader :fibonacci, :fib_nums | |
def initialize | |
@fibonacci = [0, 1] | |
end |