5 kyu
[Geometry A-1] Locate point - to the right, to the left or on the vector?
447 of 686MMMAAANNN
Loading description...
Geometry
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Python fork
.
Testing point [4658, -2364], vector [[2448, 1483], [-5715, -1431]] 1 should equal -1...
wait I think I am correct at this point... Can Someone explain it?
COBOL translation.
Approved by author
Tests are badly designed in all currently available languages (Python, CoffeeSCript, JS and Ruby): 18 real random tests, with a low probability of requiring result 0, and then 9 tests "Random point - on - vector line combinations", all expecting 0, and the user is clearly informed of this with test cases. This makes no sense, the inputs should be simply randomized, with a decent probability of having a point on the line.
I added randomized tests according to your design in Python as an additional block in the end. I hope this satisfies you (at least for Python).
It seems ok, thanks. Now other languages should be enmended too.
@MMMAAANNN Would you mind updating to python new test framework in the meantime?
Please update the kata with new python test framework.
resolved.
Hi, really enjoyed the kata. What would the likely application be for this sort of equation?
You could use it to check whether a point is inside or outside of a triangle, for example. Try this kata: http://www.codewars.com/kata/geometry-b-1-point-in-a-triangle
@MMMAAANNN: Look at the Ruby solution of @haferjir. He seems accustomed to this kind of cheating.
With my limited knowledge of Ruby, this kind of cheating is hard to prevent. But I did add a specific check for this one (he can change the solution and it will get re-accepted quite easily though).
In Ruby I think you can do
Kernel.freeze
in your function. We already have @DanielPark who cheated like that, do you remember?No, I don't remember that. And my knowledge in Ruby is not enough to adjust something like that. Can you suggest an edit in a spoiler comment or something?
I think you could simply add
Kernel.freeze
before your random tests. I tried to edit the kata and add this but I always get "Error 500, something went wrong...".I don't think I understand this:
the first test case is : vector = [[0, 0], [1, 1]] point = [0, 1] Test.assert_equals(point_vs_vector(point, vector), -1)
the way I see it the point is to the right of the vector. am I missing something ?
Yes, because it is to the left. Try to draw the arrow for the vector and the point on a piece of paper and you'll see.
stupid me... of course, I was drawing the point (1, 0) rather than (0, 1)
thanks for your help
It took me a while to notice you were talking about the left of the vector not just the left of the line drawn out by the vector.
I have updated the description. Hope it is clearer now.
Just got
point = [-6015, 3783]
andvector = [[-1639, 9654], [-1263, 4157]]
as a random test case. Seems pretty obvious that the point is left of the line segment. This graph makes that evident. Am I misinterpretting the question? The way I see it, it's asking if the point is left/right/on the line if the given line segment were extended infinitely in both directions.Vector direction is important. In this example it goes downwards, so the point is to the right of tge vector. Let me know if you need more detailed explanation.
I have updated the description. Hope it helps.
By 'left of the vector' and 'right of the vector' do you mean to the left and right of the vector line, or the left or right of the vector from the perspective of the x-axis?
The first option (relative to the vector line).
Ruby translation submitted as well and thanks for the kata; I solved it with unelegant highschool level math and didn't know the fancier way to do it which now I know :)
Thank you!
JS translation kumited.
Thank you very much.