Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ryan Stemmle #446

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
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
28 changes: 14 additions & 14 deletions day_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ This will open the day_1 directory in Atom. You should be able to see the direct

1. Check off the items below as you complete the steps you just read for each lesson. ***Remember to create a file containing your work for each lesson!***

- [ ] [A Good First Program](https://learnrubythehardway.org/book/ex1.html)
- [x] [A Good First Program](https://learnrubythehardway.org/book/ex1.html)

- [ ] [Comments in Code](https://learnrubythehardway.org/book/ex2.html)
- [x] [Comments in Code](https://learnrubythehardway.org/book/ex2.html)

- [ ] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html)
- [x] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html)

- [ ] [Variables and Names](https://learnrubythehardway.org/book/ex4.html)
- [x] [Variables and Names](https://learnrubythehardway.org/book/ex4.html)

- [ ] [Strings](https://learnrubythehardway.org/book/ex5.html)
- [x] [Strings](https://learnrubythehardway.org/book/ex5.html)

- [ ] [More Strings](https://learnrubythehardway.org/book/ex6.html)
- [x] [More Strings](https://learnrubythehardway.org/book/ex6.html)

- [ ] [Asking for Input](https://learnrubythehardway.org/book/ex11.html)
- [x] [Asking for Input](https://learnrubythehardway.org/book/ex11.html)

- [ ] Have you created 7 `ex.rb` files with your code in them?
- [x] Have you created 7 `ex.rb` files with your code in them?

1. Work through the [Strings](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#3.-strings) and [Numbers](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#5.-numbers) sections from Ruby in 100 Minutes. For each of these sections, open an `irb` session by typing `irb` into your terminal and type in the code snippets provided.

Expand All @@ -71,13 +71,13 @@ This will open the day_1 directory in Atom. You should be able to see the direct

Work through the files in the day_1/exercises directory. Complete them in this order:

1. strings
1. numbers
1. variables
1. interpolation
1. loops
1. strings x
1. numbers x
1. variables x
1. interpolation x
1. loops x

## Questions
## Questions x
- Each day contains a questions.md file where you will answer questions about what you have learned.

Answer the day 1 questions within the questions.md file. The `.md` file extension refers to markdown formatting. Markdown is a simple markup language to help format your text. [This article](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) shows everything you need for basic markdown formatting.
Expand Down
10 changes: 10 additions & 0 deletions day_1/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
puts "Hello World!"
puts "Hello Again"
puts "I like typing this"
puts "This is fun."
puts "Yay! Printing."
puts "I'd much rather you 'not'."
puts 'I "said" do not touch this'


# "Another line"
9 changes: 9 additions & 0 deletions day_1/ex2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# A comment, this is so you can read your program later.
# Anything after the # is ignored by ruby.

puts "I could have code like this." # and the comment after is ignored.

# You can also use a comment to "disable" or comment out a piece of code:
# puts "This won't run."

puts "This will run."
38 changes: 38 additions & 0 deletions day_1/ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This will print - I will now count my chickens:
puts "I will now count my chickens:"

# Prints - Hens 30
puts "Hens #{25.0 + 30.0 / 6.0}"
# Prints - Roosters 97
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"

# Prints - Now I will count the eggs:
puts "Now I will count the eggs:"

# Prints 7... It will print 6.75 if I use all floating integers.
# You cannot have .75 eggs
puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1 / 4 + 6.0

# Prints - Is it true that 3 + 2 < 5 - 7?
puts "Is it true that 3.0 + 2.0 < 5.0 - 7.0?"

# Prints - False
puts 3.0 + 2.0 < 5.0 - 7.0

# Prints - What is 3 + 2?
puts "What is 3 + 2? #{3.0 + 2.0}"
# Prints - What is 5 - 7?
puts "What is 5 - 7? #{5.0 - 7.0}"

# Prints - Oh, that's why it's false.
puts "Oh, that's why it's false."

# Prints - How about some more.
puts "How about some more."

# Prints - Is it greater? true
puts "Is it greater? #{5.0 > -2.0}"
# Prints - Is it greater or equal? true
puts "Is it greater or equal? #{5.0 >= -2.0}"
# Prints - Is it less or equal? false
puts "Is it less or equal? #{5.0 <= -2.0}"
34 changes: 34 additions & 0 deletions day_1/ex4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# There are 100 cars
cars = 100
# There is space for 4 people in a car
space_in_a_car = 4
# There are a total of 30 drivers
drivers = 30
# There are 90 passengers
passengers = 90
# Subtract the number of drivers from total cars to see cars not driven.
cars_not_driven = cars - drivers
# Number of cars driven is equal to number of drivers.
cars_driven = drivers
# Calculates total space for carpool seats
carpool_capacity = cars_driven * space_in_a_car
# Calculates average passengers per car.
average_passengers_per_car = passengers / cars_driven


puts "There are #{cars} cars available!"
puts "There are only #{drivers} drivers available."
puts "There will be #{cars_not_driven} empty cars today."
puts "We can transport #{carpool_capacity} people today."
puts "We have #{passengers} to carpool today."
puts "We need to put about #{average_passengers_per_car} in each car."

# This error in my own words: The error orginates in line rb:14.
# Because it says 'undefined' I believe the variable was likely spelled wrong.
# When you called the variable in the sentence, ruby didn't find it.

# Study drills...
# 1. 4.0 is not neccessary since we are measuring humans.
# If we just use 4, the variable output will not have a floating point.
# 2. okay
# 3. check
31 changes: 31 additions & 0 deletions day_1/ex5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name = 'Zed A. Shaw'
age = 35 # not a lie in 2009
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'

puts "Let's talk about #{name}."
puts "He's #{height} inches tall."
puts "He's #{weight} pounds heavy"
puts "Actually that's not too heavy."
puts "He's got #{eyes} eyes and #{hair} hair."
puts "His teeth are usaully #{teeth} depending on the coffee."

# this line is tricky, try to get it exactly right
puts "If I add #{age}, #{height}, and #{weight} I get #{age + height + weight}."

# Study drill

# My weight
weight_lbs = 181
# My height
height_inches = 74

# converters
lbs_to_kgs = weight_lbs * 0.454
inches_to_cm = height_inches * 2.54

puts "My weight is #{weight_lbs} pounds and #{lbs_to_kgs} kilograms."
puts "My height is #{height_inches} inches and #{inches_to_cm} centimeters."
36 changes: 36 additions & 0 deletions day_1/ex6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# The number of types of people.
types_of_people = 10
# variable with a string that includes a variable... looks like a shortcut
x = 'There are #{types_of_people} types of people.'
# variable binary equaled to a string with the work binary
binary = 'binary'
# created a variable with string 'don't.
do_not = "don't"
# short variable name with a string that links two variables.
y = 'Those who know #{binary} and those who #{do_not}.'

# prints string from variable x
puts x
# prints string from variable y
puts y

# prints a string with a variable x that includes a string
puts "I said: #{x}."
# prints another sting with variable y
puts "I also said: '#{y}'."

# creates a variable that is false
hilarious = false
# creates a variable with a string that is answered false.
joke_evaluation = "Isn't that joke so funny?! #{hilarious}"

# prints a variable
puts joke_evaluation

# creates a variable equal to a string
w = 'This is the left side of ...'
# creates a variable equal to a sentence.
e = 'a string with a right side.'

# prints two string attached by variables
puts w + e
41 changes: 41 additions & 0 deletions day_1/ex7.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# prints a string of words
puts "Mary had a little lamb."
# prints a string of words and i think it creates a variable 'snow'
# no, its a string with the word snow
puts "Its fleece was white as #{'snow'}."
# prints a string of words
puts "And everywhere that Mary went."
# prints a line of ...'s, 10 to be exact'
puts "." * 10 # what'd that do?

# variable eqaul to "C"
end1 = "C"
# variable with letter h
end2 = "h"
# variable with letter e
end3 = "e"
# variable with letter e
end4 = "e"
# variable with letter s
end5 = "s"
# variable with letter e
end6 = "e"
# variable with letter B
end7 = "B"
# variable with letter u
end8 = "u"
# variable with letter r
end9 = "r"
# variable with letter g
end10 = "g"
# variable with letter e
end11 = "e"
# variable with letter r
end12 = "r"

# watch that print vs. puts on this line what's it do?

# print prints an output without wrapping the line
print end1 + end2 + end3 + end4 + end5 + end6
# puts prints a line that wraps to the next line
puts end7 + end8 + end9 + end10 + end11 + end12
6 changes: 3 additions & 3 deletions day_1/exercises/interpolation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
name = "Ron"
team = "Chudley Cannons"

p "The #{team} are #{name}'s favorite Quidditch team"
puts "The #{team} are #{name}'s favorite Quidditch team"

# Write code that uses the variables below to form a string that reads
# "The quick red fox jumped over the lazy brown dog":
speedy = "quick red fox"
slow_poke = "lazy brown dog"

p # YOUR CODE HERE
puts "The #{speedy} jumped over #{slow_poke}"

# Write code that uses the variables below to form a string that reads
# "In a predictable result, the tortoise beat the hare!":
slow_poke = "tortoise"
speedy = "hare"

# YOUR CODE HERE
puts "In a predictable result, the #{slow_poke} beat the #{speedy}!"
8 changes: 5 additions & 3 deletions day_1/exercises/loops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

# Example: Write code that prints your name five times:
5.times do
p "Hermione Granger"
puts "Ryan Stemmle"
end

# Write code that prints the sum of 2 plus 2 seven times:
7.times do
# YOUR CODE HERE
puts 2 + 2
end

# Write code that prints the phrase 'She sells seashells down by the seashore'
# ten times:
# YOUR CODE HERE
10.times do
puts "She sells seashells down by the seashore"
end
9 changes: 4 additions & 5 deletions day_1/exercises/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
# `ruby day_1/exercises/numbers.rb`

# Example: Write code that prints the result of the sum of 2 and 2:
p 2 + 2
puts 2 + 2

# Write code that prints the result of 7 subtracted from 83:
p #YOUR CODE HERE

puts 83 - 7
# Write code that prints the result of 6 multiplied by 53:
# YOUR CODE HERE
puts 6 * 53

# Write code that prints the result of the modulo of 10 into 54:
# YOUR CODE HERE
puts 54 % 10
6 changes: 3 additions & 3 deletions day_1/exercises/strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# `ruby day_1/exercises/strings.rb`

# Example: Write code that prints your name to the terminal:
p "Alan Turing"
puts "Ryan Stemmle"

# Write code that prints `Welcome to Turing!` to the terminal:
p #YOUR CODE HERE
puts "Welcome to Turing!"

# Write code that prints `99 bottles of pop on the wall...` to the terminal:
# YOUR CODE HERE
puts "99 bottles of pop on the wall..."
19 changes: 10 additions & 9 deletions day_1/exercises/variables.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# In the below exercises, write code that achieves
# the desired result. To check your work, run this
# file by entering the following command in your terminal:
# file by entering the following command in your terminal:
# `ruby day_1/exercises/variables.rb`

# Example: Write code that saves your name to a variable and
# prints what that variable holds to the terminal:
name = "Harry Potter"
p name
name = "Ryan Stemmle"
puts name

# Write code that saves the string 'Dobby' to a variable and
# prints what that variable holds to the terminal:
house_elf = "Dobby"
# YOUR CODE HERE
puts house_elf

# Write code that saves the string 'Harry Potter must not return to Hogwarts!'
# and prints what that variable holds to the terminal:
# YOUR CODE HERE
x = "Harry Potter must not return to Hogwarts!"
puts x

# Write code that adds 2 to the `students` variable and
# prints the result:
students = 22
# YOUR CODE HERE
p students
students = students + 2
puts students

# Write code that subracts 2 from the `students` variable and
# prints the result:
# YOUR CODE HERE
p students
students = students - 2
puts students
17 changes: 17 additions & 0 deletions day_1/new_calc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# I need to calculate how many hours I have to work on my boat this month.


puts "How many hours remaining? Let's do it one day at a time."

puts "How many days remaining? January 2 to the 23. #{23 - 2}"

puts "How many working hours per day? 6"

puts "Let's multiply #{23 - 2} times 6"

puts (23 - 2) * 6

puts "But, there is 2 people! So lets double it!"

puts (23 - 2) * 6 * 2
Loading