From 6a8b2ebccc248895619dd6ece08b296330c2b7e0 Mon Sep 17 00:00:00 2001 From: harish-datla <36021808+harish-datla@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:48:29 +0530 Subject: [PATCH 1/7] feat:[practice] hello world example --- exercises/practice/hello-world/lib/hello_world.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/practice/hello-world/lib/hello_world.ex b/exercises/practice/hello-world/lib/hello_world.ex index bae289edf6..d4582392cd 100644 --- a/exercises/practice/hello-world/lib/hello_world.ex +++ b/exercises/practice/hello-world/lib/hello_world.ex @@ -4,6 +4,6 @@ defmodule HelloWorld do """ @spec hello :: String.t() def hello do - "Goodbye, Mars!" + "Hello, World!" end -end +end \ No newline at end of file From a36ad2b0050237083bf656987855b6cbcc148916 Mon Sep 17 00:00:00 2001 From: harish-datla <36021808+harish-datla@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:20:39 +0530 Subject: [PATCH 2/7] feat: Update lasagna.ex --- exercises/concept/lasagna/lib/lasagna.ex | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/exercises/concept/lasagna/lib/lasagna.ex b/exercises/concept/lasagna/lib/lasagna.ex index 1cc18e8cce..aca84bc934 100644 --- a/exercises/concept/lasagna/lib/lasagna.ex +++ b/exercises/concept/lasagna/lib/lasagna.ex @@ -1,11 +1,7 @@ defmodule Lasagna do - # Please define the 'expected_minutes_in_oven/0' function - - # Please define the 'remaining_minutes_in_oven/1' function - - # Please define the 'preparation_time_in_minutes/1' function - - # Please define the 'total_time_in_minutes/2' function - - # Please define the 'alarm/0' function + def expected_minutes_in_oven(), do: 40 + def remaining_minutes_in_oven(time_spent), do: expected_minutes_in_oven() - time_spent + def preparation_time_in_minutes(layers), do: 2*layers + def total_time_in_minutes(layers,time_spent), do: preparation_time_in_minutes(layers) + time_spent + def alarm(), do: "Ding!" end From ff4b78f66c2ce5fc876e321112b87df522bdad33 Mon Sep 17 00:00:00 2001 From: harish-datla <36021808+harish-datla@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:36:20 +0530 Subject: [PATCH 3/7] feat: Update pacman rules --- exercises/concept/pacman-rules/lib/rules.ex | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/exercises/concept/pacman-rules/lib/rules.ex b/exercises/concept/pacman-rules/lib/rules.ex index c2c6e3acec..83442208bc 100644 --- a/exercises/concept/pacman-rules/lib/rules.ex +++ b/exercises/concept/pacman-rules/lib/rules.ex @@ -1,17 +1,14 @@ defmodule Rules do def eat_ghost?(power_pellet_active?, touching_ghost?) do - # Please implement the eat_ghost?/2 function + power_pellet_active? and touching_ghost? end - def score?(touching_power_pellet?, touching_dot?) do - # Please implement the score?/2 function + touching_power_pellet? or touching_dot? end - def lose?(power_pellet_active?, touching_ghost?) do - # Please implement the lose?/2 function + not power_pellet_active? and touching_ghost? end - def win?(has_eaten_all_dots?, power_pellet_active?, touching_ghost?) do - # Please implement the win?/3 function + has_eaten_all_dots? and not lose?(power_pellet_active?, touching_ghost?) end end From 727f6e60c0fdfeff16599ccf2cd3668c930e0d8b Mon Sep 17 00:00:00 2001 From: harish-datla <36021808+harish-datla@users.noreply.github.com> Date: Sat, 9 Mar 2024 14:12:59 +0530 Subject: [PATCH 4/7] feat: Update freelancer_rates.ex Signed-off-by: harish-datla <36021808+harish-datla@users.noreply.github.com> --- .../concept/freelancer-rates/lib/freelancer_rates.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/concept/freelancer-rates/lib/freelancer_rates.ex b/exercises/concept/freelancer-rates/lib/freelancer_rates.ex index 5b46e3bf4d..9fec2a7c5c 100644 --- a/exercises/concept/freelancer-rates/lib/freelancer_rates.ex +++ b/exercises/concept/freelancer-rates/lib/freelancer_rates.ex @@ -1,17 +1,17 @@ defmodule FreelancerRates do def daily_rate(hourly_rate) do - # Please implement the daily_rate/1 function + 8.0*hourly_rate end def apply_discount(before_discount, discount) do - # Please implement the apply_discount/2 function + before_discount*(100-discount)*(1/100) end def monthly_rate(hourly_rate, discount) do - # Please implement the monthly_rate/2 function + ceil(apply_discount(8*22*hourly_rate, discount)) end def days_in_budget(budget, hourly_rate, discount) do - # Please implement the days_in_budget/3 function + Float.floor(budget/apply_discount(daily_rate(hourly_rate), discount),1) end end From 6b793ddb9ac78497139b93e64877d851d8ef55cc Mon Sep 17 00:00:00 2001 From: harish-datla <36021808+harish-datla@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:06:31 +0530 Subject: [PATCH 5/7] deat: Update secrets.ex Signed-off-by: harish-datla <36021808+harish-datla@users.noreply.github.com> --- exercises/concept/secrets/lib/secrets.ex | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/concept/secrets/lib/secrets.ex b/exercises/concept/secrets/lib/secrets.ex index e9e7297d1a..0fa3df31ec 100644 --- a/exercises/concept/secrets/lib/secrets.ex +++ b/exercises/concept/secrets/lib/secrets.ex @@ -1,29 +1,29 @@ defmodule Secrets do def secret_add(secret) do - # Please implement the secret_add/1 function + &(&1 + secret) end def secret_subtract(secret) do - # Please implement the secret_subtract/1 function + &(&1 - secret) end def secret_multiply(secret) do - # Please implement the secret_multiply/1 function + &(&1*secret) end def secret_divide(secret) do - # Please implement the secret_divide/1 function + &(Integer.floor_div(&1,secret)) end def secret_and(secret) do - # Please implement the secret_and/1 function + &(Bitwise.band(&1,secret)) end def secret_xor(secret) do - # Please implement the secret_xor/1 function + &(Bitwise.bxor(&1,secret)) end def secret_combine(secret_function1, secret_function2) do - # Please implement the secret_combine/2 function + &(secret_function2.(secret_function1.(&1))) end end From f2545baa0dbf0a34c2e489b2ef10f7f71c4bb6c4 Mon Sep 17 00:00:00 2001 From: harish-datla <36021808+harish-datla@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:34:12 +0530 Subject: [PATCH 6/7] feat: Update log_level.ex Signed-off-by: harish-datla <36021808+harish-datla@users.noreply.github.com> --- exercises/concept/log-level/lib/log_level.ex | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/exercises/concept/log-level/lib/log_level.ex b/exercises/concept/log-level/lib/log_level.ex index b8548d5c41..1146187f4a 100644 --- a/exercises/concept/log-level/lib/log_level.ex +++ b/exercises/concept/log-level/lib/log_level.ex @@ -1,9 +1,23 @@ defmodule LogLevel do def to_label(level, legacy?) do - # Please implement the to_label/2 function + cond do + level == 0 and not legacy? -> :trace + level == 1 -> :debug + level == 2 -> :info + level == 3 -> :warning + level == 4 -> :error + level == 5 and not legacy? -> :fatal + true -> :unknown + end end def alert_recipient(level, legacy?) do - # Please implement the alert_recipient/2 function + label = to_label(level,legacy?) + cond do + label == :error || label == :fatal -> :ops + label == :unknown && legacy? -> :dev1 + label == :unknown -> :dev2 + true -> false + end end end From fc2fc924369a34f07c3a02fcded31bb9045f1c7a Mon Sep 17 00:00:00 2001 From: harish-datla <36021808+harish-datla@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:34:44 +0530 Subject: [PATCH 7/7] refactor: Update log_level.ex Signed-off-by: harish-datla <36021808+harish-datla@users.noreply.github.com> --- exercises/concept/log-level/lib/log_level.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/concept/log-level/lib/log_level.ex b/exercises/concept/log-level/lib/log_level.ex index 1146187f4a..a584505912 100644 --- a/exercises/concept/log-level/lib/log_level.ex +++ b/exercises/concept/log-level/lib/log_level.ex @@ -14,7 +14,7 @@ defmodule LogLevel do def alert_recipient(level, legacy?) do label = to_label(level,legacy?) cond do - label == :error || label == :fatal -> :ops + label in [:error,:fatal] -> :ops label == :unknown && legacy? -> :dev1 label == :unknown -> :dev2 true -> false