7 kyu
Fix the base conversion function!
417Caders
Loading description...
Debugging
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 new test framework is required. updated in this fork
good kata
This comment has been hidden.
Regarding return value description says
#The output should be a string at all times
, alsoFix his convert_num() function so it correctly converts a base-10 integer
so you should check if passed input is anint
.No, more specifically; bool data types have different expected values, check the test cases.
(anyways, solved this thing through some trial and error)
This kata favors certain way of type checking and uses certain property of booleans that is present in python. Description doesn't deviate from actual task and as such I don't see it being an issue, more of hidden trickiness.
Makes sense, thanks!
@Caders
,Your tests are backwards. If you look at the Codewars Python docs, you will see this:
test.assert_equals(actual, expected, message)
"{actual} should be {expected}".format(actual=actual, expected=expected)
The error messages get messed up because your tests are written like this:
test.assert_equals(expected, actual)
Instead of using
print
statements above each test, you should usetest.it('describe your test here...')
. That is why your kata is not compatible with Python 3.Lastly, you need random tests. Make sure to use
range
instead ofxrange
so that your random tests are compatible with both versions of Python.Thanks!
@zebulan,
Thank you so much for the suggestion, I need all the help I can get!
I've updated the testing as you suggested, let me know if there are any other improvements to be made!
@Caders
,Thanks for the fast response!
Since you asked about other improvements, I started making a list but it was getting a bit long so I thought it might be better if I updated them myself and let you look at them:
test.assert_equals
(unless you wanted to change the format/output of the error message)0
inside ofrange(start, stop, step)
since start defaults to0
i
for anything you could replace it with_
->for _ in range(50):
cant_touch
inside ofPreloaded Code
, everyone can access it... just put it inside ofTest Cases
return cant_touch(number, base)
random.randint
?Hopefully you don't mind the changes!
EDIT:
Of course, after my own comment bringing up the backwards tests that's what I ended up doing to the random tests haha. I just fixed that after looking at it again. They should match
test.assert_equals(actual, expected)
now.Thanks for the tip on
range()
!What does using the
_
do in arange()
rather thani
? Or is it just to avoid use ofi
anywhere else?My bad, I thought the docs said that Preloaded Code wasn't accessible by the user!
I really appreciate the changes, I'll definitely be updating my other kata to match the standard! :D
It's basically just a throwaway value. It just indicates that the value isn't going to be used for anything.
EDIT: https://stackoverflow.com/questions/5893163/what-is-the-purpose-of-the-single-underscore-variable-in-python
Preloaded code is great if (for example) you had a big dictionary that everyone was supposed to use in their solution. If you didn't put it in the preloaded section, every single solution would have to copy/paste that same dictionary. I like to look through maybe the first 20 or 30 solutions after I solve a kata but if there is the same dictionary that is massive in each one, I don't really spend as much time looking through other solutions.
It can be used for other things too, helper functions, classes, etc. Anything that you just don't want to have duplicated in each solution (at least that's how I look at it!).
Thank you for the further explanation and swift replies!
I'll keep all of these things in mind going forward, and hopefully (admittedly probably not) won't need too much more help in the future.
Thanks!
@Caders
,No problem at all. I have only authored a single kata so far, so I don't want to give the impression that I know all the ins and outs of the authoring process. I just solve katas for fun/learning but after solving almost 1000 katas (mostly Python, some JavaScript), I am just used to seeing the test cases and the patterns involved.
I have learned so much using Codewars that I like to try and give back in whatever small way I can.
Keep up the great work on your katas, I've enjoyed a few of them so far! (I'm just about to start
Colored hexes
)