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
puts "RUBY SYNTAX" | |
puts "" | |
puts "Question: Ruby Typing Practice" | |
puts "" | |
puts "You should practice typing Ruby code until it feels natural." | |
puts "You should be able to type Ruby code as fast as you can type English." | |
puts "Go through each slide in the lecture and type each line of code you find into irb." | |
puts "Code is always written in the Courier font. Do not copy-and-paste." | |
puts "There are traps in the slides that will get you into trouble if you do that." | |
puts "When you're done, just respond to this question with 'ok'." |
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
#Defining all the possible outcomes | |
numbererror = "I don't understand what you said. You need to type 1, 2 or 3." | |
lettererror = "I didn't catch that. You need to type K for keep or T for trade." | |
door1 = "MILLION DOLLARS" | |
door2 = "DOLLAR BILL" | |
door3 = "WHOLE LOT OF NOTHING" | |
prizepic1 = " | |
XXXXXXXXXXXXXXXXXXFEDERAL RESERVE NOTEXXXXXXXXXXXXXXXXXXX | |
XXX XX THE UNITED STATES OF AMERICA XXX XX | |
XXXX XX ------- ------------ XXXX XX |
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
puts "How much did the meal cost?" | |
inputok = false | |
until inputok == true do | |
mealprice = gets.chomp.to_f | |
if mealprice > 0 | |
mealprice = (mealprice*1.20).round(2).to_s.split(".") | |
inputok = true | |
else |
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
# Add 2 to the number. | |
def add_two(number) | |
if number.respond_to? :+ | |
if number.respond_to? :push | |
number.push 2 | |
elsif number.is_a?(String) | |
number.to_f + 2 | |
else | |
number + 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
def bigger_num (num1, num2) | |
if num1 > num2 | |
puts num1 | |
elsif num2 > num1 | |
puts num2 | |
else | |
puts "equal" | |
end | |
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
def float_fixer (num = 0, *rest) | |
if num.is_a?(Float) | |
num = num.to_s.split(".") | |
d = (num[0]).to_i | |
c = num[1] | |
if c.to_i < 10 | |
c = (c+"0").to_i |
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
def max_refactor (*rest) | |
rest.sort.last | |
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
(1..100).each { |i| | |
if i % 3 == 0 and i % 5 !=0 | |
i = "Fizz" | |
elsif i % 5 == 0 and i % 3 != 0 | |
i = "Buzz" | |
elsif i % 3 == 0 and i % 5 == 0 | |
i = "FizzBuzz" | |
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
def perpetual_NYE | |
10.downto(0).each {|i| | |
sleep 1 | |
puts i | |
} | |
perpetual_NYE | |
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
require "./wyncodemodules.rb" | |
WyncodeTests.float_fixer_test | |
WyncodeTests.bignum_digits_test | |
WyncodeTests.join_split_test | |
WyncodeTests.hash_genetics_test | |
WyncodeTests.class_methods_comparison_test |
OlderNewer