From 669eeaa8fe3f2c797cda96130600e4c70973a8fa Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Thu, 14 Nov 2024 22:45:30 -0600 Subject: [PATCH 1/8] first commit --- .tool-versions | 1 + Gemfile.lock | 80 +++++++++++++++------------- session1/3-challenge/1_arithmetic.rb | 2 +- 3 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..0531904f5 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 2.5.0 diff --git a/Gemfile.lock b/Gemfile.lock index 8bd2d69c2..f39179957 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -61,4 +67,4 @@ RUBY VERSION ruby 2.5.0p0 BUNDLED WITH - 1.16.1 + 1.16.6 diff --git a/session1/3-challenge/1_arithmetic.rb b/session1/3-challenge/1_arithmetic.rb index 049ece773..50146edce 100644 --- a/session1/3-challenge/1_arithmetic.rb +++ b/session1/3-challenge/1_arithmetic.rb @@ -9,5 +9,5 @@ # arithmetic1(-6) # => -50 def arithmetic1(n) - + (n * 5) - 20 end From 9ea655a4fab88f43c345638b7f594ca1dfd85608 Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Thu, 14 Nov 2024 22:49:50 -0600 Subject: [PATCH 2/8] second question answered --- session1/3-challenge/2_arithmetic.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/session1/3-challenge/2_arithmetic.rb b/session1/3-challenge/2_arithmetic.rb index 21445b427..7526e0e5d 100644 --- a/session1/3-challenge/2_arithmetic.rb +++ b/session1/3-challenge/2_arithmetic.rb @@ -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 From 0fcb47dd1bbeb541f86762464ab2acf035a0f8db Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Thu, 14 Nov 2024 23:00:11 -0600 Subject: [PATCH 3/8] simple logic --- session1/3-challenge/3_simple_logic.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/session1/3-challenge/3_simple_logic.rb b/session1/3-challenge/3_simple_logic.rb index 29f8c5037..bcd372ca1 100644 --- a/session1/3-challenge/3_simple_logic.rb +++ b/session1/3-challenge/3_simple_logic.rb @@ -8,4 +8,9 @@ # ten_twenty(6) # => 10 def ten_twenty(n) + if n % 2 == 0 + 10 + else + 20 + end end From 2383075136f5f1f1960f09fba418e6220ce1b70b Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Thu, 14 Nov 2024 23:17:07 -0600 Subject: [PATCH 4/8] logic completed --- session1/3-challenge/4_logic.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/session1/3-challenge/4_logic.rb b/session1/3-challenge/4_logic.rb index 015c11bac..a98a28986 100644 --- a/session1/3-challenge/4_logic.rb +++ b/session1/3-challenge/4_logic.rb @@ -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 From afedd35f536025cba322104e23c2303f2020e38c Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Fri, 15 Nov 2024 09:07:43 -0600 Subject: [PATCH 5/8] string replacement --- session1/3-challenge/5_string.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/session1/3-challenge/5_string.rb b/session1/3-challenge/5_string.rb index ed15e87ad..fdc82520e 100644 --- a/session1/3-challenge/5_string.rb +++ b/session1/3-challenge/5_string.rb @@ -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 \ No newline at end of file + string.gsub('sad', 'happy').gsub('Sad', 'Happy') +end From 64ff5b0113d5a09a094947c60e23b99bc72fcb1a Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Fri, 15 Nov 2024 09:44:15 -0600 Subject: [PATCH 6/8] string 6 complete --- session1/3-challenge/6_string.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/session1/3-challenge/6_string.rb b/session1/3-challenge/6_string.rb index 4dc3a4e83..acccf38f7 100644 --- a/session1/3-challenge/6_string.rb +++ b/session1/3-challenge/6_string.rb @@ -6,5 +6,9 @@ # def odds_and_evens(string, return_odds) - -end \ No newline at end of file + 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 From 97ea62e66f98bfda2a7a12db4e61cd21ae4e25c3 Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Sat, 16 Nov 2024 20:54:25 -0600 Subject: [PATCH 7/8] 1:7 complete --- session1/3-challenge/7_string.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session1/3-challenge/7_string.rb b/session1/3-challenge/7_string.rb index 841278b6a..aa4b4fd0b 100644 --- a/session1/3-challenge/7_string.rb +++ b/session1/3-challenge/7_string.rb @@ -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 From b4992bbe5b277bc2e4a5c1ed693ccc3405984541 Mon Sep 17 00:00:00 2001 From: Chris Jeanson Date: Sat, 16 Nov 2024 21:17:06 -0600 Subject: [PATCH 8/8] 2:1 done --- session2/3-challenge/1_input_output.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/session2/3-challenge/1_input_output.rb b/session2/3-challenge/1_input_output.rb index 99f723341..bc257cf2c 100644 --- a/session2/3-challenge/1_input_output.rb +++ b/session2/3-challenge/1_input_output.rb @@ -8,6 +8,6 @@ # "11\n7\n18\n" to standard output. def sum_difference_product - # your code goes here - -end \ No newline at end of file + a, b = gets.split.map(&:to_i) + puts [a + b, a - b, a * b] +end