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

Master to main merge 9/3/2024 #1448

Closed
wants to merge 7 commits into from
Closed
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
8 changes: 4 additions & 4 deletions exercises/concept/freelancer-rates/lib/freelancer_rates.ex
Original file line number Diff line number Diff line change
@@ -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
14 changes: 5 additions & 9 deletions exercises/concept/lasagna/lib/lasagna.ex
Original file line number Diff line number Diff line change
@@ -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
18 changes: 16 additions & 2 deletions exercises/concept/log-level/lib/log_level.ex
Original file line number Diff line number Diff line change
@@ -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 in [:error,:fatal] -> :ops
label == :unknown && legacy? -> :dev1
label == :unknown -> :dev2
true -> false
end
end
end
11 changes: 4 additions & 7 deletions exercises/concept/pacman-rules/lib/rules.ex
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions exercises/concept/secrets/lib/secrets.ex
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions exercises/practice/hello-world/lib/hello_world.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ defmodule HelloWorld do
"""
@spec hello :: String.t()
def hello do
"Goodbye, Mars!"
"Hello, World!"
end
end
end