6 kyu
Find the First Number in Having a Certain Number of Divisors I
322 of 936raulbc777
Loading description...
Fundamentals
Mathematics
Data Structures
Dynamic Programming
Memoization
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.
Nice kata.
( JS )
Random tests don't run because of nested
it
s.ETA: translation doesn't abide by
numDiv < 80
either.python new test framework is required. updated in this fork
.
i know, because has number 10, min number is 48
help
who can tell me
find_min_num(10) = 48 # divisors are: 1, 2, 3, 4, 6, 8, 12, 16, 24 and 48
10 => divisors are: 1, 2, 3, 4, 6, 8, 12, 16, 24 and 48 this means?
why 10 divisors are: 1, 2, 3, 4, 6, 8, 12, 16, 24 and 48
"There will be a next kata with numDiv < 10000" numDiv=9999 and the decision will, by all appearances, be = 91695537858773979462999063778453094400 BigInt (for JavaScript, for example) allowed?
D language
source/solution_test.d(3,8): Error: module
solution
importadd
not found /usr/bin/dmd failed with exit code 1.#11b34/3qa:0z:vV
this kata was challenging
Go translation
D translation
Approved! +1
Sample tests are wrong.
JS Node 14. should be enabled
Python new test framework should be used
Ruby 3.0 should be enabled
JS done
python done.
Ruby done
Dynamic programming tag should be removed
Description should be language-agnostic
My algorithm passed all test till a cetain number (for i:1 to n<8000), but failed when n>=10000 due to algorithm time execution (o=(10000)). I need a better data structure to handle this in a shorter time. Refactoring to reduce an algorithm complexity is not my favorite.
Rust translation.
Approved by author secretly
Also, there are problems with the random test cases:
numDiv < 80
but random test cases go up to 100.numDiv
the corresponding is really huge, which is impossible to calculate on the fly without timeing out; in fact, even the random test cases don't touch those values. It's very misleading to just saynumDiv < 80
(or 100) when some of the possible values are practically untouchable and hence not considered.This comment has been hidden.
I passed all tests but this one: 120 should equal 4096. But doesn't 4096 only have 13 divisors? Also the question details specify that numDiv < 100, why would 120 be in the test?
Hi wing_clover. In this kata you have to create a kata that outputs the minimum number that has a certain quantity of divisors
numDiv
(this is the argument that the function receives). In other words, if you start your search from n = 1, you should output the first number in having this amount of divisors.In the given case, if
numDiv = 13
, the function outputs4096
. That means what I've explained you the line above. There is no number, (starting fron n = 1) that has this exact quantity of divisors. Of course that there are numbers less than4096
that have more divisors than13
.120
is a divisor of4096
, that's why is in the list. What the kata says is that the argumentnumDiv < 100
for the random tests.I hope that the explanation will help you to solve the kata. Until now,
115
codewarriors have solved it.Thank you very much for the reply. It was my bad. I thought the test was telling me if numDiv = 120, the function outputs 4096.
Hi, I am new here and have the same problem when trying to solve this kata in Python as wing_clover had. If the argument num_div is 13, then the first number with 13 divisors is 120: 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 120. It is true that 4096 has 13 divisors (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096) but it is not the smallest number with 13 divisors. I also don't understand raulbc777's statement '120 is divisor of 4096' which is obviously not true.
Didn't you forget 30, 40 and 60 as divisors of 120 there? 120 has 16 divisors, not 13. In "120 should equal 4096" error message for
find_min_num(13)
, the first value is what the user's function wrongly returned and the expected one was the other one, 4096. About120 is a divisor of 4096, that's why is in the list.
I don't know what he meant there, but it's wrong.I get this error
test(MinNbDivTest) Fixed Tests Test Passed test1(MinNbDivTest) Random Tests Process was terminated. It took longer than 10000ms to complete Any idea how to solve it?
Since the question details specify that
numDiv < 100
, there needs to be a test case of wherenumDiv = 97
. All of current solutions will time out (including mine), at least for Ruby.The purpose of this kata is to solve it using a brute force algorithm. If we put some number of divisors like 97, all the solutions will not pass. I will change the maximum number of divisors if you want but I'm not going to include for this kata heavy tests. I will prepare a kata in January with number of divisors < 10000
The maximum number of divisors was corrected in the details.
The real problem is that any prime number greater than 19 will cause any brute force algorithm to time out, so I don't think the maximum number of divisors is really the issue. Perhaps specify that the algorithm will be tested only on composite numbers < 100?
Yes, you're right. Some number of divisors even less than 80 will be unreachable for our 6000 ms. I'll fix the details related to this. Then I'll message to the creator of the translations.
This comment has been hidden.
I wrote method, what returns first int value, what have assigned count of divisions(Is this correct task?) but your tests does something wrong - for example: on the row MinNbDiv.findMinNum(7) test returns "expected:<64> but was:<24>" we can count it now: 24 divisions are: 1,2,3,4,6,8,12,24 - 8 (8>7 so it must be correct answer) there is more issues like this, cause if I'll add this to my code: "if(num == 7)return 64;" to escape this error, i'll get some more from random test(for example "expected:<3600> but was:<2520>") I think there are some errors in this kata tests;
hi @pickwik, Which programming language please?
@raulbc777, java and there some troubles with text displaying, so there are something, what was not shown in first comment: for example: on the row MinNbDiv.findMinNum(7) test returns "expected: 64 but was: 24"
@pickwik Could you post what the tests answer between 3 backticks? Moreover you can be sure at 99% that the tests are not wrong...
24 has 8 divisors and you are asked for 7 divisors, so your answer is wrong!-(
@g964, thx, so I misunderstand the task. This is not a issue;
牛逼,牛逼!
English please!
你能看得懂我说的是啥意思不?
No. I guess that most users here don't understand Chinese. If you want to talk to others, write in English.
haode xiexie nide tixing!
That's… still not English. But you're welcome.
(⊙o⊙)
Haskell version doesn't follow Haskell conventions:
find_min_num
should befindMinNum
.Corrected! You can mark the issue as resolved.
It's solved. Thanks bkaes for your observation.