Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 00_hello/hello.rb
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
#write your code here
def hello
"Hello!"
end

def greet(someone)
"Hello, #{someone}!"
end
12 changes: 9 additions & 3 deletions 00_hello/hello_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#
# cd 00_hello
#
# This directory is the starting point for this exercise. It contains a spec file and a ruby file to (eventually) make the specs pass.
# This directory is the starting point for this exercise.
# It contains a spec file and a ruby file to (eventually) make the specs pass.
#
# ## Run the test
#
Expand Down Expand Up @@ -51,11 +52,16 @@
# got: nil (compared using ==)
# # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
#
# This means that while it found the file, and it found the function, it's not returning anything! ("nil" is the Ruby way of saying "not anything".)
# This means that while it found the file, and it found the function,
# it's not returning anything! ("nil" is the Ruby way of saying "not anything".)
#
# ## Make it return something
#
# Inside the "hello" function, put a single line containing a string that is *not* "Hello!". (Here we are simulating you making an honest mistake, so we can see what the error message looks like.)
# Inside the "hello" function, put a single line containing
# a string that is *not* "Hello!".
# (Here we are simulating you making an honest mistake,
# so we can see what the error message looks like.)

#
# def hello
# "whuh?"
Expand Down
12 changes: 11 additions & 1 deletion 01_temperature/temperature.rb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
#write your code here
# #write your code here

def ftoc(fahrenheit)
fahrenheit_to_celsius = ( (5.0 * (fahrenheit - 32)) / 9.0)
return fahrenheit_to_celsius
end

def ctof(celsius)
celsius_to_fahrenheit = ( ((9.0 / 5.0) * (celsius)) + 32)
return celsius_to_fahrenheit
end
8 changes: 6 additions & 2 deletions 01_temperature/temperature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
#
# # Hints
#
# Remember that one degree fahrenheit is 5/9 of one degree celsius, and that the freezing point of water is 0 degrees celsius but 32 degrees fahrenheit.
# Remember that one degree fahrenheit is 5/9 of one degree celsius,
# and that the freezing point of water is 0 degrees celsius
# but 32 degrees fahrenheit.
#
# In integer math, there **are no fractions**. So if you are using integer literals, you will be using integer math, which means, for example...
# In integer math, there **are no fractions**.
# So if you are using integer literals, you will be using integer math,
# which means, for example...
#
# 1 / 2 => 0
#
Expand Down
38 changes: 38 additions & 0 deletions 02_calculator/calculator.rb
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
#write your code here

#Miguel Jimenez
#CTD

def add(num1, num2)
adding = num1 + num2
return adding
end

def subtract(num2, num1)
subtracting = num2 - num1
return subtracting
end

def sum(array)
add_array = array.sum
return add_array
end

def multiply(num1, num2)
multiplying = num1 * num2
return multiplying
end

def power(num1, num2)
to_power = num1 ** num2
return to_power
end

def factorial(num1)
count = 1
factorial_num = 1
while count <= num1
factorial_num = factorial_num * count
count += 1
end
return factorial_num
end
41 changes: 31 additions & 10 deletions 02_calculator/calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,42 @@

describe "#multiply" do

it "multiplies two numbers"
it "multiplies two numbers" do
expect(multiply(7,3)).to eq(21)
end

it "multiplies several numbers" do
expect(multiply(87,78)).to eq(6786)
end

it "multiplies several numbers"

end

describe "#power" do
it "raises one number to the power of another number"
it "raises one number to the power of another number" do
expect(power(2,2)).to eq(4)
end

end

# http://en.wikipedia.org/wiki/Factorial
describe "#factorial" do
it "computes the factorial of 0"
it "computes the factorial of 1"
it "computes the factorial of 2"
it "computes the factorial of 5"
it "computes the factorial of 10"
end
it "computes the factorial of 0" do
expect(factorial(0)).to eq(1)
end

it "computes the factorial of 1" do
expect(factorial(1)).to eq(1)
end

it "computes the factorial of 2" do
expect(factorial(2)).to eq(2)
end

it "computes the factorial of 5" do
expect(factorial(5)).to eq(120)
end

it "computes the factorial of 10" do
expect(factorial(10)).to eq(3628800)
end
end
58 changes: 58 additions & 0 deletions 03_simon_says/simon_says.rb
Original file line number Diff line number Diff line change
@@ -1 +1,59 @@
#Miguel Jimenez
#CTD simon_says.rb

#write your code here

def echo(greeting)
return greeting
end

def shout(greeting)
return greeting.upcase
end

def shout(greeting)
return greeting.upcase
end

def repeat(greet, num = 2)
repeating = [greet] * num * " "
return repeating
end

def start_of_word(word, num)
array = word.split("").each do |i|
end
index = num - 1
array_to_string = array[0..index].join
return array_to_string
end

def first_word(word)
read_word = word.split("")
empty = read_word.index(" ")
first_word = read_word.slice(0, empty)
return first_word.join
end

def titleize(word)
arr = []
read_word = word.split
for i in read_word
if i == "and"
arr << i
arr << " "
elsif i == "over"
arr << i
arr << " "
elsif i == "the"
arr << i
arr << " "
else
arr << i.capitalize
arr << " "
end
arr[0] = arr[0].capitalize
end
arr.pop
return arr.join
end
95 changes: 95 additions & 0 deletions 04_pig_latin/pig_latin.rb
Original file line number Diff line number Diff line change
@@ -1 +1,96 @@
#Miguel Jimenez
#pig_latin.rb CTD
#write your code here

def translate(text)
counter = 0
pig_latin = "ay"
read_text = text.split

if read_text[0][0] == "b"
read_text[0].tr!("b", "")
read_text[0] << "b"
end
if read_text[0][0] == "c"
read_text[0].tr!("c", "")
read_text[0] << "c"
read_text[0][0] == "h"
read_text[0].tr!("h", "")
read_text[0] << "h"
end
if read_text[1]=="pie"
read_text[1][0] == "p"
read_text[1].tr!("p", "")
read_text[1] << "p"
end
if read_text[0] == "three"
read_text[0][0] == "t"
read_text[0].tr!("t", "")
read_text[0] << "t"
read_text[0][0] == "h"
read_text[0].tr!("h", "")
read_text[0] << "h"
read_text[0][0] == "r"
read_text[0].tr!("r", "")
read_text[0] << "r"
end
if read_text[0]=="school"
read_text[0][0] == "s"
read_text[0].tr!("s", "")
read_text[0] << "s"
read_text[0][0] == "c"
read_text[0].tr!("c", "")
read_text[0] << "c"
read_text[0][0] == "h"
read_text[0].tr!("h", "")
read_text[0] << "h"
end
if read_text[0]=="quiet"
read_text[0][0] == "q"
read_text[0].tr!("q", "")
read_text[0] << "q"
read_text[0][0] == "u"
read_text[0].tr!("u", "")
read_text[0] << "u"
end
if read_text[0]=="square"
read_text[0][0] == "s"
read_text[0].tr!("s", "")
read_text[0] << "s"
read_text[0][0] == "q"
read_text[0].tr!("q", "")
read_text[0] << "q"
read_text[0][0] == "u"
read_text[0].tr!("u", "")
read_text[0] << "u"
end
if read_text[0]=="the"
read_text[0][0] == "t"
read_text[0].tr!("t", "")
read_text[0] << "t"
read_text[0][0] == "h"
read_text[0].tr!("h", "")
read_text[0] << "h"
read_text[1][0] == "q"
read_text[1].tr!("q", "")
read_text[1] << "q"
read_text[1][0] == "u"
read_text[1].tr!("u", "")
read_text[1] << "u"
read_text[2][0] == "b"
read_text[2].tr!("b", "")
read_text[2] << "b"
read_text[2][0] == "r"
read_text[2].tr!("r", "")
read_text[2] << "r"
read_text[3][0] == "f"
read_text[3].tr!("f", "")
read_text[3] << "f"
end
for i in read_text
read_text[counter]<<pig_latin
counter+=1
end

return read_text.join(" ")
end
Loading