6 kyu
Simple Fun #258: Is Divisible By 6
403 of 1,214myjinxin2015
Loading description...
Puzzles
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.
Really simple yet cool kata :D (I took the easy way)
1234567890123456789012345678*0 not divisible by 6.
Read the description again. * is a masked char, and the numbers in the example in the description are divisible by 6. Not a kata issue.
JS
chai
&&assert
should be usedPython new test framework should be used
Python update to new test framework: https://www.codewars.com/kumite/64ad9e6a362be62fa0eb9940
In JS's output: leading zeros must be discarded, but not in other languages
Leading zeroes must be discarded in Python too.
Sample tests in Ruby cannot compile in Ruby 3.0
Before that, I was not aware of the problems of the % operator with large numbers in JavaScript.
Current test case: Test.assert_equals(is_divisible_by_6("*"),["6"]) Current kata description: "find all the possible options to replace the asterisk with a digit to produce an integer divisible by 6." As 0 is divisible by 6 and the current kata description does not require the resultant integer to be non-zero, please either (a) fix the kata to include 0 as a valid answer or (b) fix the kata's description to exclude 0 as a valid answer. Thanks.
Which language are you using?
Python, thanks.
Hmmm.... @GiacomoSorbi's bad translations... Here is my original testcase in JS:
As you can see,
0
is a valid result. I'll fix those things as soon as possible ;-)Ruby and Crystal translations fixed. Now working for Python ;-)
Python fixed.
0 is divisible by 6…
See, e.g. https://www.wolframalpha.com/input/?i=first+ten+numbers+divisible+by+6 👨🏼🏫
EDIT: Raised an issue about it.
This comment has been hidden.
xxxx%2==0
is incorrect.Without xxxx%2==0 it passes few more tests, but for number to be divisible by 6, sum of its digits must be divisible by 3 and also even.
My bad. Number must be even, not the sum of its digits. Back to the drawing board ;-)
Had to submit twice, a couple of the random tests on the first submission were bogus. Second submission worked.
This comment has been hidden.
Sounds like you are not using Python ;-) HaHaHaHa...
This comment has been hidden.
@GiacomoSorbi, Could you do this?
And the Ruby modulo or % solution.
Hey, The large sample that is with number more than 50 digits the modulus operator doesnt work in Javascript
You should thinking out a way to do this, instead of convert it to the number format ;-)
We don't want a solution like
return n%6==0
;-)This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
@tachyonlabs,Thanks ;-)
Python and Crystal translations submitted as well, fixed small trouble in my Ruby version; thanks for your kata :)
small trouble? leading zeros? ;-)
No, I meant my trouble, not your trouble (for not giving more detailed specs): I just generated too large numbers.
Fixed now.
There is another issue about
zeros
;-) https://www.codewars.com/kata/simple-fun-number-223-parameter-of-number/discuss#5911f18caee4318a4f000045That is indeed; thanks for the heads up :+1:
@GiacomoSorbi, Thanks for your translation. Please have a look at your translations, and make sure no
leading zeros
appears in your random tests ;-)I can implement it now, but it was not in the specs and it would be more like a chore for solvers, mh...
A bit strange, isn't it? ;-)
@myjinxin2015 learning from your katas i think you have secret books about Algorithm and Mathematics.Would you care to share 'em ? :)
No such books, just coding and coding :D
alright, then :)