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

Create mentoring.md for Triangle exercise #2361

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions tracks/csharp/exercises/triangle/triangle/mentoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
We need to check first if the triangle is a triangle.
```
static bool IsTriangle(double a, double b, double c) => a + b > c && a + c > b && b + c > a;
```
Then, all of the methods have to invoke it as a first step and add the rest of the condition
```
public static bool IsEquilateral(double a, double b, double c) => IsTriangle(a,b,c) && a == b && b == c;
public static bool IsIsosceles(double a, double b, double c) => IsTriangle(a,b,c) && (a == b || b == c || a == c);
public static bool IsScalene(double a, double b, double c) => IsTriangle(a,b,c) && (a != b && b != c && a != c);
```
As in the example above, all of them can be one-line methods set with lambda expression,
here is a helpful part of the documentation for [lambda expression](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-operator#expression-body-definition)

You may also make a remark that lambda expression aren't only related to C#, they are also used in different languages like [javascript/typescript](https://www.tutorialspoint.com/how-to-use-lambda-expression-in-typescript#:~:text=Lambda%20expressions%2C%20commonly%20referred%20to,defining%20functions%20in%20both%20languages.)
Loading