7 kyu
Simple eviternity numbers
312 of 1,087KenKamau
Loading description...
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.
Passing all tests but timing out due to long runtime heh, interesting kata.
def solve(a, b): isEviternity = 0
your code being too slow is not a kata issue ;-)
I never said anything about a kata issue, I just said it's interesting because I'll have to figure out a faster method.
you did raise an issue though. don't do that, they are meant to report bugs within the kata
huh, apparently I did, I thought this was just regular discourse, mb
All languages should have such sample and fixed tests to prevent solutions with wrong inclusive-upper-bound checking. (
<= b
instead of< b
)a = 8, b = 888
-->13
Fixed in Python
Python new test framework
C#: method name should be
PascalCase
(Please refer to implementation of backward compatibility here )Prolog translation
Approved
The code passed on the upper bound (500000) but times out on random tests? How is this possible? Or am I supposed to pass all 45 random tests in 12 seconds?
Maybe pre-generate the values beforehand or resort to a combination-based approach. Also your latest solution is wrong as you have taken
558
etc. into account.Any tips how to optimize the performance?
I already tried to, but still too slow. My code is in the reply so other people can see this question.
This comment has been hidden.
Maybe building different combinations of 3,5,8 instead of excluding from whole range?
That is one viable solution yes.
You could derive the 3 numbers dynamically instead of hardcoading them to 3, 5, and 8. This could avoid the trivial solution of pasting in a series of numbers and instead force the use of an algorithmic solution.
If solved algorithmatically, there is no way this should be ranked as 7 kyu.
Interesting, may I know how?
Not really a suggestion pertaining to this kata, but may be worth making as another kata instead.
This comment has been hidden.
Please don't post solutions in Discourse.
There are a lot of tests in 'Attempt' so you run out of time with viable solution. Since this is low level kata maybe :
If you think that this is a performance Kata, then you are in trouble.
It's either performance Kata or math Kata. Either way it's not 7 kyu Kata.
It's not a performance kata, but it deserves at least a 6 kyu in my opinion. I solved it in JS and it demanded "more advanced" functionalities not to time out. I encountered 6 kyu katas much much easier than this one.
I'm confused.. How come number 35 is not the eviternity number? It contains 3 and 5 and the number of didgits is equal.. What am I missing ?
So in number 35 count of the 8 is 0. Hence it is not satisfying the given condition which says count of 8's >= count of 5's >= count of 3's. for 35 it is 0 >= 1 >= 1 which is false.
This comment has been hidden.
Tests are wrong or description is inaccurate.
There must be at least one
8
in the number according to the tests, but the description includes situations like this:7 --> 0 >= 0 >= 0
.Well, the tests were wrong in a way and they are now fixed.
Not sure what you mean by
7 --> 0 >= 0 >= 0
.Confirm issue resolved.
Sorry, I wrote that in a hurry.
The number
7
has zero8
, zero5
, and zero 3 digits. Since0 >= 0 >= 0
,7
fits the description as written, but examples and tests suggest these types of numbers should not be counted. The requirement for numbers to only have the digits 3, 5, and 8 should probably be descriptive rather than only by example. (Additionally, there is a typo in the first example code box in the descriptionnot -> note
.)I'll mark as resolved since looking more closely this is probably more of a strong suggestion than an issue.
Cheers.
I have updated the description as suggested.
The placement of the
comprise of digits 8, 5 and 3 only
statement is bad: shouldn't it go to the beginning? Like this:Thanks. Will update.
There seems to be a problem with the python random tests, e.g.:
That's basically all 3, 4 and 5 digit numbers, which is 103 - 4 = 99, confirmed by the sample tests
The description doesn't say that these numbers can only have the digits
3, 5, 8
suggestion: remove "simple" from the title ;-)
I've added a line that states that there are only numbers
3, 5 and 8
.You are correct that solve(90,139701) == 99. There was a bug in the ref solution. Now fixed.
Please confirm.
Tests are OK now.
How about removing "simple" from the title?
JS version Are you sure about random tests? Most of them expect
Expected: 2496
. I can only pass fixed tests :(Please refresh. I've amended the ranges to make it more reasonable.
2496
is correct.This comment has been hidden.
I believe the tests are wrong -- I have the same issue in python (see above)
( JavaScript )
My naive but very probably correct solution gets this before the time-out:
I highly doubt the random tests are correct.
Guys, all fixed now. Thanks for your patience.
Please refresh and give it another go.
I also go the execution Timeout from the server, tests are probably still not ideal.
It's already fixed in every language, check your code instead ;-)