From 013d95f699eb1547b00016d776964b86b6516d98 Mon Sep 17 00:00:00 2001 From: Mohamed-Mehdi-Gara Date: Thu, 13 May 2021 17:47:15 +0100 Subject: [PATCH 1/4] 01_basics solution --- intro/01_basics/family.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/intro/01_basics/family.rb b/intro/01_basics/family.rb index b20700e..aca4f21 100644 --- a/intro/01_basics/family.rb +++ b/intro/01_basics/family.rb @@ -6,3 +6,7 @@ # Your code goes here +age_sum = mom + dad + john + mary +result = (mom * dad)/(john - mary) +puts "Sum of ages = #{age_sum}" +puts "Result = #{result}" \ No newline at end of file From 7888767adfdb3c6c4fcedf9567a9e314efd32767 Mon Sep 17 00:00:00 2001 From: Mohamed-Mehdi-Gara Date: Fri, 14 May 2021 16:57:00 +0100 Subject: [PATCH 2/4] edited names.rb --- intro/02_control_flow/names.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/intro/02_control_flow/names.rb b/intro/02_control_flow/names.rb index e360f0d..298567e 100644 --- a/intro/02_control_flow/names.rb +++ b/intro/02_control_flow/names.rb @@ -6,3 +6,12 @@ # Your code goes here +avg_length = (name1.length + name2.length + name3.length + name4.length)/ 4 +puts "What is your name" +my_name = gets + +if (my_name.length < avg_length.size) + puts "#{my_name} is shorter than average" +else + puts "#{my_name} is longer than average" +end From b795daefff1af4b53aaeb03e59d86a1da16f78d4 Mon Sep 17 00:00:00 2001 From: Mohamed-Mehdi-Gara Date: Fri, 14 May 2021 17:21:17 +0100 Subject: [PATCH 3/4] edited fibonacci.rb --- intro/03_loops/fibonacci.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/intro/03_loops/fibonacci.rb b/intro/03_loops/fibonacci.rb index a81c6fa..4128557 100644 --- a/intro/03_loops/fibonacci.rb +++ b/intro/03_loops/fibonacci.rb @@ -2,3 +2,7 @@ # Your code goes here +def fibo(n) + n <= 2 ? 1 : fibo(n-1) + fibo(n-2) + end + p (1..10).map{|x| fibo(x)} \ No newline at end of file From 65f680d3d9cc66241a68e552828657e49a947ceb Mon Sep 17 00:00:00 2001 From: Mohamed-Mehdi-Gara Date: Mon, 17 May 2021 10:04:22 +0100 Subject: [PATCH 4/4] edited queen.rb --- intro/04_data_structures/queen.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/intro/04_data_structures/queen.rb b/intro/04_data_structures/queen.rb index 9d0ca4e..1cae3cf 100644 --- a/intro/04_data_structures/queen.rb +++ b/intro/04_data_structures/queen.rb @@ -1,9 +1,6 @@ # A little bit of classic rock -lyrics = "Is this the real life?"\ - "Is this just fantasy?"\ - "Caught in a landslide,"\ - "No escape from reality." +lyrics = "Is this the real life?\nIs this just fantasy?\nCaught in a landslide,\nNo escape from reality." # Your code goes here - +puts lyrics.each_char.tally #=> {"I"=>2, "s"=>8, " "=>13, "t"=>7, "h"=>4, "i"=>6, "e"=>7, "r"=>3, "a"=>8, "l"=>5, "f"=>3, "?"=>2, "\n"=>3, "j"=>1, "u"=>2, "n"=>3, "y"=>2, "C"=>1, "g"=>1, "d"=>2, ","=>1, "N"=>1, "o"=>2, "c"=>1, "p"=>1, "m"=>1, "."=>1}