6 kyu
How Many Numbers?
443 of 1,069raulbc777
Loading description...
Fundamentals
Algorithms
Mathematics
Data Structures
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.
Quite interesting kata.
I enjoyed it..
Nice Kata.
Really fun, but waaaay to hard for 6 kyu, solved a 4 kyu before that was on the same level or even easierf :) Still great Kata, 10/10 regarding of fun
python new test framework is required. updated in this fork
approved by original author.
I have fixed up an old Factor translation.
Note that the changes to the description you see under
diff
are merely due to the difference between the old version and current description, there are no actual changes.Approved +1. Thanks for making this version in Factor.
Go translation
Approved! +1
D translation
Approved! +1
Inconsistency in input range regarding
n
among languages:Also fixed tests have input up to 95K, but random tests have lower input generation which at least should be the same
Description should be language agnostic (First sentence) and reworded + reformatted as describe below
EDIT: The lower && upper boundaries of
n
andd
should also be mentioned explicitlyLanguage agnostic done in this fork
Python new test framework should be used
done.
JS Node 18. should be enabled
Ruby 3.0 should be enabled
Enabled in this fork
nice and interesting kata ; )
Rust translation.
Approved by author
Replace this:
with something like this:
Because 8991 doesn't satisfy bullet point number 2.
Done in this fork
Details are so hard to understand
Not an issue. Please rephrase on how you wanted the description to be
Empty
it
blocks must be removed from tests.done.
Description formatting is broken.
Fixed in this fork
Factor translation awaiting approval!
Hello, I think I found an error:
max_sum_dig (4.8ms)
[[1,2]]
Sounds like https://github.com/Codewars/codewars.com/issues/1909
Try clicking the language version selection (even there's only one version available and it looks selected). This should update the language version stored in your solution. Try again after that.
This should be fixed, if not, please raise an issue agn
The description says
It's clear that 1 <= d <= 8
where in random tests there isd = randint(1, 9)
I spent quite some time before I realized that it should beIt's clear that 1 <= d <= 9
d
is the difference between two digits, so the max dif (given the digits can't be 0) is8 = 9-1
.Well, it may be that I understood it wrong. After reading
1 <= d <= 8
I assumed that this is initial condition and in tests I gotd = 9
. So maybe it's just about wording.I've tested for returned values of d and you're right, it returns 9 sometimes, I think it deserves a check from @raulbc777 then. Leave the issue open until then.
Fixed! Now randint(1,8) in Javascript. Thanks for the feedback!
@raulbc777 the same thing for elixir -
:random.uniform/1
returns value between 1 and n inclusive, so in testsd = 1 + :random.uniform(8)
should be changed tod = :random.uniform(8)
Constraint #3 was worded a little confusing to me: "They cannot have digits that occurs twice or more. Example: 8991 should be discarded."
I read this as no digit can be repeated at all in the number, regardless if repeated digits are next to each other or not. I wrote my code to make this constraint but after I didn't pass some of the tests and reread #3 with your example, I rewrote my code to assume you meant the number can't contain repeated digits that are touching and passed all the tests.
Actually, considering that the digits have to be in icreasing order, repeated digits have to be contiguous. So, in fact, your algorithm wasn't following the specs when you encounter this trouble. ;)
This comment has been hidden.
bruh don't post solution :\
Haskell translation kumited.
Java translation kumited.
Nice and fun kata:
Two minor issues:
1.I was able to brute force this kata. I feel like this should not be possible and a test or tests should be included to cause my solution and others like it to time out.
2.The description states that n is the upper limit inclusive. My solution excludes n from the list of possible values and still passes. Consider adding a test in which n itself is a passable value.
Thanks for a great kata.
ok, let's see if I may reduce a bit some tests. I'll be waiting your answer. Try in 10 minutes. I'll include some cases when nmax belongs to this set of numbers.
I had to go up to around
n = 10**7
to hit the 6 second limit using my algorithm. A test liketest.assert_equals(sel_number(23, 2), 3)
causes my algorithm to fail, since 23 should be included and my algorithm does not include it.Sorry, I didn't understand before. I put your code in my solution box and it works pretty fine. I passed all the tests. Let's see point num.2 now
Working on some katas to resolve some issues. I added the test
test.assert_equals(sel_number(47, 3), 12)
.47
is a special number that coincides withn
.I enjoyed this kata, thanks @raulbc777!
In the description it says: "Create a function sel_num()..." and then the first few example test cases use a function with the same name but the last few use the full function name of sel_number().
I think you should change the names of the functions to all be sel_number(). Other than that I think this kata is ready!
Thanks for your observations. Now the function is
sel_number()
. It was one of my first katas. As you can see, nobody had expressed something about that before you did. Thanks a lot. You may check it. It's solvedI enjoy your katas, keep up the good work!
Nice kata, raulbc. There's a minor typo in the kata description under list item (2)—the first example given for the increasing digit order constraint is 769. Maybe that 7 should be a different digit?
Thanks, laoris. Now it is fixed, I substitute the confussing 769 for 789. Thanks for your time.
Hi, nice Kata, but I think there is a problem with your tests or your description. :(
On the basis of the description running with
n = 1000, d = 1
, I would expect the following list of valid numbers:The length of this list is 15 items, but the test expected 64 as the response.
Oh thanks a lot ChristianECooper for your time and contribution. You are completely right. I detected duplicates and my code was allowing numbers with higher difference in the contiguous digits. I have solved it. I appreciate your contribution for CW.