Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Can data be transferred as numbers or a list?
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/121.
Please join the discussion to help us identify duplicate kata and retire them.
Really nice initiation and practice to those unfamiliar with class construction. Thanks for the kata!
Thanks sooo much! After adding the == method, everything worked well!
I got the same problem.
Make sure to implement the __eq__(equal) method correctly, the v1==v2 method.
I am stuck in this challenge. Would be really grateful if someone can direct me. Having these errors
Expected: #<Vector:0x000056332da9c0c0 @coordinates=[1, 2, 3]>, instead got: #<Vector:0x000056332da9c1b0 @coordinates=[1, 2, 3]> from the creation test and
Expected: #<Vector:0x000056332da92a98 @coordinates=[0, 0, 0]>, instead got: #<Vector:0x000056332da92b60 @coordinates=[0, 0, 0]>
Expected: #<Vector:0x000056332da92598 @coordinates=[2, 4, 6]>, instead got: #<Vector:0x000056332da92688 @coordinates=[2, 4, 6]>
from the addition & subtraction tests
I know the objects id's does not match but I am creating a new object on both methods
Description of the kata did not state that a tuple can be passed as an argument however in the random test, a tuple was passed instead of a list.
Vector([a,b,c]) # creates a new Vector from the supplied 3D array. Vector(a,b,c) # same as above
Answer to myself and maybe others:
The tests do not want to compare the instances, as they (hopefully) are always different.
Take care of this early and all will be fine :)
Maybe this was the same error I'm running into:
#<Vector:0x0000559eb6bc3b08 @x=1, @y=2, @z=3>, instead got: #<Vector:0x0000559eb6bc3f68 @x=1, @y=2, @z=3>
in my implementation, although the initialization itselfs seems to do, what it is supposed to.
Yes, using getter and setter is a better way. But that is not what this kata asks for.
The exact same question was answered in the third post below yours.
Magnitude is not a method, it should be implemented as a property.
The tests for my solution pass except for exit... curious if this is an issue with the test (code in python):
Traceback (most recent call last):
File "main.py", line 19, in
test.assert_approx_equals(Vector(examples).magnitude, 3.741, 0.001)
File "/runner/frameworks/python/cw-2.py", line 84, in assert_approx_equals
div = max(abs(actual), abs(expected), 1)
TypeError: bad operand type for abs(): 'method'
Loading more items...