Skip to content
Merged
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
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule ExercisesElixir.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:credo, "~> 1.7.0", only: [:dev, :test], runtime: false}
{:credo, "~> 1.7.11", only: [:dev, :test], runtime: false}
]
end
end
8 changes: 4 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%{
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"credo": {:hex, :credo, "1.7.11", "d3e805f7ddf6c9c854fd36f089649d7cf6ba74c42bc3795d587814e3c9847102", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "56826b4306843253a66e47ae45e98e7d284ee1f95d53d1612bb483f88a8cf219"},
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
}
4 changes: 2 additions & 2 deletions modules/20-data-types/10-atoms-and-tuples/lib/solution.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ defmodule Solution do
end

# BEGIN
def is_point_inside_circle(point, circle) do
def point_inside_circle?(point, circle) do
{:circle, center, radius} = circle
distance(point, center) <= radius
end

def is_point_inside_rect(point, rect) do
def point_inside_rect?(point, rect) do
{:point, x, y} = point
{:rect, left_top, right_bottom} = rect
{:point, left_x, top_y} = left_top
Expand Down
12 changes: 6 additions & 6 deletions modules/20-data-types/10-atoms-and-tuples/ru/EXERCISE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Реализовать функцию `is_point_inside_circle(point, circle)`, которая принимает точку и окружность, и возвращает `true`, если точка находится внутри окружности, или `false`, если точка находится снаружи.
Реализовать функцию `point_inside_circle?(point, circle)`, которая принимает точку и окружность, и возвращает `true`, если точка находится внутри окружности, или `false`, если точка находится снаружи.

Реализовать функцию `is_point_inside_rect(point, rect)`, которая принимает точку и прямоугольник, и возвращает `true`, если точка находится внутри прямоугольника, или `false`, если точка находится снаружи.
Реализовать функцию `point_inside_rect?(point, rect)`, которая принимает точку и прямоугольник, и возвращает `true`, если точка находится внутри прямоугольника, или `false`, если точка находится снаружи.

Точка представлена кортежем `{:point, x, y}`.

Expand All @@ -13,14 +13,14 @@

```elixir
point = {:point, 50, 50}
Solution.is_point_inside_circle(point, {:circle, {:point, 10, 10}, 100})
Solution.point_inside_circle?(point, {:circle, {:point, 10, 10}, 100})
# => true
Solution.is_point_inside_circle(point, {:circle, {:point, -10, -10}, 20})
Solution.point_inside_circle?(point, {:circle, {:point, -10, -10}, 20})
# => false

point = {:point, -10, 20}
Solution.is_point_inside_rect(point, {:rect, {:point, -20, 30}, {:point, 20, 10}})
Solution.point_inside_rect?(point, {:rect, {:point, -20, 30}, {:point, 20, 10}})
# => true
Solution.is_point_inside_rect(point, {:rect, {:point, 0, 0}, {:point, 10, 10}})
Solution.point_inside_rect?(point, {:rect, {:point, 0, 0}, {:point, 10, 10}})
# => false
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ defmodule Test do

test "point inside circle" do
point = {:point, 50, 50}
assert is_point_inside_circle(point, {:circle, {:point, 10, 10}, 100})
assert not is_point_inside_circle(point, {:circle, {:point, -10, -10}, 20})
assert point_inside_circle?(point, {:circle, {:point, 10, 10}, 100})
assert not point_inside_circle?(point, {:circle, {:point, -10, -10}, 20})
end

test "point inside rect" do
point = {:point, -10, 20}
assert is_point_inside_rect(point, {:rect, {:point, -20, 30}, {:point, 20, 10}})
assert not is_point_inside_rect(point, {:rect, {:point, 0, 0}, {:point, 10, 10}})
assert point_inside_rect?(point, {:rect, {:point, -20, 30}, {:point, 20, 10}})
assert not point_inside_rect?(point, {:rect, {:point, 0, 0}, {:point, 10, 10}})
end
end
2 changes: 1 addition & 1 deletion modules/45-structs/50-any-protocols/test/solution_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Test do
end

test "for robot" do
assert Teller.impl_for(%Robot{}) == Teller.Any
assert Teller.impl_for(%Robot{}) == Teller.Robot
assert Teller.say_something(%Robot{name: "Roberto"}) == "World!"
end
end
Expand Down