Skip to content

Commit

Permalink
Add comments for crystal analyzer 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
meatball133 committed Aug 7, 2024
1 parent e1bcb4a commit e04c8d0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
14 changes: 14 additions & 0 deletions analyzer-comments/crystal/darts/hypot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Pow

Using the `pow`, `sqrt` or `**` is totally valid and can be neassisary in many situations.
However when wanting a distance in 2d space we can use the [`hypot` method][hypot] which returns the hypotenuse of the x and y lengths.

```crystal
# Rather than:
Math.sqrt(number ** 2 + another_number ** 2)
# Consider:
Math.hypot(number, another_number)
```

[hypot]: https://crystal-lang.org/api/Math.html#hypot%28value1%2Cvalue2%29-instance-method
5 changes: 5 additions & 0 deletions analyzer-comments/crystal/darts/uses_hypot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Uses the hypot method

Congratulations, your solution uses the hypot method!

Your solution uses an efficient way of calculating the distance from the center of a dartboard and that's worth taking a moment to celebrate.
2 changes: 1 addition & 1 deletion analyzer-comments/crystal/sieve/do_not_use_div_rem.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Like the instructions mention, the purpose of this exercise is to build a Sieve of Eratosthenes without the use of operations such as division or modulo division.
Please refer to the [Wikipedia link][wikipedia] for a description of the algorithm.

Building the Sieve of Eratosthenes in an immutable language such as Crystal may feel a bit unnatural,
Building the Sieve of Eratosthenes without operations such as division or modulo division can be tricky.
but it is a beautiful algorithm invented more than two millennia ago that is worth learning and implementing.

[wikipedia]: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
4 changes: 4 additions & 0 deletions analyzer-comments/crystal/weighing-machine/missing_method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Missing %{method_name} method call

Like the instructions mention, the purpose of this exercise is to learn about getters and setters.
Manually defining these methods is not inherently bad can lead to code which is more verbose and harder to maintain.

0 comments on commit e04c8d0

Please sign in to comment.