generated from exercism/generic-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
1.3 (#40)
* Started refactoring * Update docker image and add more comments * Update representer dependecy * Update weighing machine comment system * Fix path * Fix result
1 parent
54a68ef
commit 947aa2a
Showing
12 changed files
with
98 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"files": { | ||
"solution": [ | ||
"src/darts.cr" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"crystal.ameba.warning","params":{"message":"Useless assignment to variable `value`","line_number":5},"type":"actionable"},{"comment":"crystal.darts.hypot","params":{},"type":"actionable"},{"comment":"crystal.darts.uses_hypot","params":{},"type":"celebratory"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Darts | ||
extend self | ||
|
||
def score(x : Number, y : Number) : Number | ||
value = x ** 2 + y ** 2 | ||
hypot = Math.hypot(x, y) | ||
if hypot <= 1 | ||
10 | ||
elsif hypot <= 5 | ||
5 | ||
elsif hypot <= 10 | ||
1 | ||
else | ||
0 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"files": { | ||
"solution": [ | ||
"src/weighing_machine.cr" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"comments":[{"comment":"crystal.ameba.convention","params":{"message":"Trailing whitespace detected","line_number":17},"type":"informative"},{"comment":"crystal.weighing-machine.missing_method","params":{"method_name":"getter"},"type":"essential"},{"comment":"crystal.weighing-machine.missing_method","params":{"method_name":"setter"},"type":"essential"},{"comment":"crystal.weighing-machine.missing_method","params":{"method_name":"property"},"type":"essential"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class WeighingMachine | ||
def precision : Int32 | ||
@precision | ||
end | ||
|
||
def metric=(value : Bool) : Bool | ||
@metric = value | ||
end | ||
|
||
def weight : Float64 | ||
@weight | ||
end | ||
|
||
def weight=(value : Float64) : Float64 | ||
@weight = value | ||
end | ||
|
||
def initialize(precision : Int32, metric : Bool = true) | ||
@precision = precision | ||
@metric = metric | ||
end | ||
|
||
# DO NOT MODIFY ANYTHING BELOW THIS LINE | ||
def weigh : String | ||
weight = @metric ? @weight : @weight * 2.20462 | ||
weight = weight.round(@precision) | ||
weight.to_s | ||
end | ||
end |