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

first commit #399

Open
wants to merge 8 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
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 2.5.0
80 changes: 43 additions & 37 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
capybara (2.18.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
capybara (3.35.3)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
diff-lcs (1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
diff-lcs (1.5.1)
helloworld (0.0.1)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
mustermann (1.0.2)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
public_suffix (3.0.2)
rack (2.0.4)
rack-protection (2.0.1)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
mustermann (2.0.2)
ruby2_keywords (~> 0.0.1)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
public_suffix (4.0.7)
racc (1.8.1)
rack (2.2.10)
rack-protection (2.2.4)
rack
rack-test (0.8.3)
rack (>= 1.0, < 3)
rake (12.3.0)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rack-test (2.1.0)
rack (>= 1.3)
rake (13.2.1)
regexp_parser (2.9.2)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
sinatra (2.0.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.1)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
ruby2_keywords (0.0.5)
sinatra (2.2.4)
mustermann (~> 2.0)
rack (~> 2.2)
rack-protection (= 2.2.4)
tilt (~> 2.0)
tilt (2.0.8)
xpath (3.0.0)
tilt (2.4.0)
xpath (3.2.0)
nokogiri (~> 1.8)

PLATFORMS
Expand All @@ -61,4 +67,4 @@ RUBY VERSION
ruby 2.5.0p0

BUNDLED WITH
1.16.1
1.16.6
2 changes: 1 addition & 1 deletion session1/3-challenge/1_arithmetic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# arithmetic1(-6) # => -50

def arithmetic1(n)

(n * 5) - 20
end
5 changes: 5 additions & 0 deletions session1/3-challenge/2_arithmetic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@
# arithmetic2(-6, -7) # => -3.5

def arithmetic2(a, b)
if a <= b
a.to_f / 2
else
b.to_f / 2
end
end
5 changes: 5 additions & 0 deletions session1/3-challenge/3_simple_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
# ten_twenty(6) # => 10

def ten_twenty(n)
if n % 2 == 0
10
else
20
end
end
9 changes: 9 additions & 0 deletions session1/3-challenge/4_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@


def grade(num_books, has_read_books)
base_grade = case num_books
when 0...10 then 'D'
when 10..20 then 'C'
else 'B'
end

grades = ['A', 'B', 'C', 'D']
grade_index = grades.index(base_grade)
has_read_books ? grades[grade_index - 1] : base_grade
end


5 changes: 3 additions & 2 deletions session1/3-challenge/5_string.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Given a string, replace every instance of sad to happy
#
#
# add_more_ruby("The clowns were sad.") # => "The clowns were happy."
# add_more_ruby("The sad dad said sad stuff.") # => "The happy dad said happy stuff."
# add_more_ruby("Sad times are ahead!") # => "Happy times are ahead!"

def add_more_ruby(string)
end
string.gsub('sad', 'happy').gsub('Sad', 'Happy')
end
8 changes: 6 additions & 2 deletions session1/3-challenge/6_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
#

def odds_and_evens(string, return_odds)

end
if return_odds == true
(1..string.length-1).step(2).map { |i| string[i] }.join
else
(0..string.length-1).step(2).map { |i| string[i] }.join
end
end
2 changes: 1 addition & 1 deletion session1/3-challenge/7_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") # => "arrrrrrrr"

def pirates_say_arrrrrrrrr(string)

string.each_char.each_cons(2).select { |a,b| a.downcase == 'r' }.map(&:last).join
end
6 changes: 3 additions & 3 deletions session2/3-challenge/1_input_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
# "11\n7\n18\n" to standard output.

def sum_difference_product
# your code goes here

end
a, b = gets.split.map(&:to_i)
puts [a + b, a - b, a * b]
end