7 kyu
Thinkful - Object Drills: Vectors
1,556 of 1,892Grae-Drake
Description:
Create a Vector
class with x
and a y
attributes that represent component magnitudes in the x and y directions.
Your vectors should handle vector additon with an .add()
method that takes a second vector as an argument and returns a new vector equal to the sum of the vector you call .add()
on and the vector you pass in.
For example:
>>> a = Vector(3, 4)
>>> a.x
3
>>> a.y
4
>>> b = Vector(1, 2)
>>> c = a.add(b)
>>> c.x
4
>>> c.y
6
Adding vectors when you have their components is easy: just add the two x components together and the two y components together to get the x and y components for the vector sum.
Fundamentals
Object-oriented Programming
Similar Kata:
Stats:
Created | Jan 18, 2017 |
Published | Jan 18, 2017 |
Warriors Trained | 2550 |
Total Skips | 22 |
Total Code Submissions | 6415 |
Total Times Completed | 1892 |
Python Completions | 1556 |
JavaScript Completions | 365 |
Total Stars | 27 |
% of votes with a positive feedback rating | 91% of 279 |
Total "Very Satisfied" Votes | 234 |
Total "Somewhat Satisfied" Votes | 40 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 12 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |