7 kyu
Adding words - Part I
581 of 1,873osofem
Loading description...
Mathematics
Fundamentals
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.
The kata is nice, but maybe 6 kyu rate will be more appropriate for this one. And also I think that adding the OOP tag would be useful
python new test framework is required. updated in this fork
Approved
Java translation
Please review.
This comment has been hidden.
You're mutating number property in add method, you shouldn't.
I fixed it. TY. But can you shortly explain why it works that way? Quick search didn't help.
Why is does mutate if it is just re-assignment of value which can be used just ok anytime?
Let's say you create a "three", its value should stay at
3
, then you add "seven" and get "ten", then you have the same "three" and add "eight" to it, you'd expect you'd get "eleven", when you mutated the value, you'll get "eighteen" instead. I don't know if this helps (that's what the sample tests do, create a single number and add different values to it).I don't get it\ Has it something to do with conctructor or what? Does it call twice method? this.number=3 => (add method)this.number=10 =>(returning)=>in the process of returning it takes this.number=10(already from add method) and calls one more time => (add.method)this.number=18 ////////Why it calls method twice? /// I fixed kata with other variable but I want to find out how to make it work initial way, if there is such way of course.
@osofem, thanks for the nice kata. But I think that it was more logical to change the current value of the object when using the add method.
It's too late to change the task after 7 years, which will invalidate all solutions.
This comment has been hidden.
Fixed
Actually it would be even better to not use
rand
andsrand
at all in C++. Instead one should use the functions from the random-header from C++11.This comment has been hidden.
Please specify the language you are using?
You're right, sorry. I am using Python.
study on what self does, and how instances of classes work
there is only 1 object tested. example:
x = Arith("five") print(x.add("seven")) this should return "twelve"
I don't see the point of having 2 parts of the 'Adding words' kata. If you solved the second part first (like I did) you can just copy the solution to part I and it will work.
I enjoyed figuring this out! Thanks for the Kata.
I don't really see the point of making POO for such a tiny need.
It's clearly written in the description that this is one of series of katas. The kata is going towards this i.add("one").minus("two").divide("four")
This comment has been hidden.
Ruby and Python translations, please check and accept :-)
Both approved :)
JavaScript by convention uses camelCase, where identifiers start with a lowercase letter. Capitalised identifiers are reserved for constructor functions (which arith is), and fully uppercased identifiers are reserved for constants (which n is not).
CodeWars recommends following these de facto standards.
With a little work, you can change the tests to expect either Trotter or trotter if you don't want to invalidate existing solutions.
Please follow conventions.
.
Good job!