6 kyu

Count the divisible numbers

1,436 of 3,616joh_pot
Description
Loading description...
Fundamentals
Algorithms
  • Please sign in or sign up to leave a comment.
  • blr_Oliver Avatar

    It's not algorithm problem, it's pure math. Suggest to remove tag Algorithms, add tag Mathematics and reduce difficulty level to 7 kyu.

  • timleungtech Avatar

    This kata looked easy at first but I did not realize a solution faster than linear time was required. After writing out a few test cases and all the possible combinations that returns the same answer, I was finally able to connect the dots for a solution in constant time.

  • Lukas Pottmann Avatar

    I'm either 1 too high with half the test cases in one "solution" or 1 too low in half the cases in another, are the test cases alright??

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • marcosantoniodev Avatar

    I have no idea how to resolve with no timeout problems, I'm using a linear aproach...

  • dante_cws Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • Vladimir-82 Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • akar-0 Avatar
  • akar-0 Avatar

    C: k is not random in random tests.

  • benjaminzwhite Avatar

    All of the comments about how this is a "maths" problem rather than a "coding" problem remind me of the classic S. Harris cartoon:

    I'm on the verge of a major breakthrough

  • abstractsins Avatar

    This comment has been hidden.

  • mseverini Avatar

    I think there may be an error in one of the ruby examples? I think (11,345,17) should yeild 19 no?

  • user1430804 Avatar

    interesting..

  • fulerent Avatar

    This Kata is amazing. I have decided the kate for three attempts. I wrote five or six solutions, but they didn't work. My result has 10 string on finish. It is little, I thought, but after I saw a solution as 1 return and all. Wow! It is a easy kate and a easy decide. And I have decided now her:)

  • akar-0 Avatar
  • akar-0 Avatar
  • user9644768 Avatar

    Ruby 3.0 should be enabled, see this to learn how to do it

    Please organize the structure of test fixture as following (although it has been mentioned in the attached link, I'm repeated here again)

    describe "<This message should describe the categories of test groups inside this block>" do
      it "<A short message describing this test group>" do
        expect(...).to eq(...) #Assertions
        #Or Test.assert_equals(user_response, reference_response)
      end
    end
    
  • chustos96 Avatar

    it got me trying like 2 hours to get de constant time one, good challenge

  • jamnjerry Avatar

    This comment has been hidden.

  • Autrach Avatar

    I've read the discussions and found out that i need a different approach other than using the loops because of the time limit. Can anyone suggest how to go about it? thanks :)

  • kavinbharathii Avatar

    one test case is flawed

    divibible_count(0, 1, 7), 0 should equal 1
    

    there a no multiples of 7 between 0 and 1

  • raveneer Avatar

    add tests

    x -2 y 2 k 2 , 3 x -1 y 1 k 2 , 1

  • B1ts Avatar
  • Sharad85 Avatar

    This comment has been hidden.

  • Sharad85 Avatar

    After solving the prob, when clicked on 'Run Sample Test' gives attempt successfull, but when clicked on 'Attempt' gives error as 'Execution Timed Out (12000 ms)'! Tried this prob offline with various eg and it works fine. Pls looks into this issue!!

  • Bevybizzle Avatar

    This comment has been hidden.

  • fibonaccios Avatar

    Can someone explain to me how,

    x = 0 y = 1 k = 7

    should expect 1?

    python!

  • Pengles Avatar

    This comment has been hidden.

  • 3rdDayzombie Avatar

    This comment has been hidden.

  • Unnamed Avatar

    Negative numbers are currently allowed, but there are no such tests.

  • crandalj Avatar

    This comment has been hidden.

  • crandalj Avatar

    This is not a 6kyu problem with the optimization requirements being imposed.

    Please specify in the Details section that you are forced to be O(1) and that loop based solutions will not work.

  • Madjosz Avatar
  • Krasi Avatar

    This comment has been hidden.

  • ivan_polyansky Avatar

    I passed all the test.. but it seems that JS has error during the attempt, like -> FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory <-

    AND, I don't quite understand this error: [1:0x56268f39e000] 2775 ms: Mark-sweep 580.4 (592.2) -> 580.4 (592.2) MB, 95.0 / 0.0 ms allocation failure GC in old space requested

    please fix this.. thank you

  • kn9ka Avatar

    This comment has been hidden.

  • uniapi Avatar
  • micahwiesner67 Avatar

    Hi I have found a solution that works for all basic cases and the cases I have used in my terminal in Python. I have been using a list comprehension and get a memory error on the full set of test cases, presumably I need to optimize my function. I have read that I could use generators though I don't have an idea of how to set up a generator such that it optimizes memory and can still count all of the occurrences of those divisibly by k. Any help?

  • dolamroth Avatar

    Nice, but IMHO too easy for 6 kyu.

  • Dk221 Avatar

    This comment has been hidden.

  • anter69 Avatar

    Ruby translation kumited -- please check and approve.

  • SteveArray Avatar

    How exactly does 1 go into 7, one time?

  • Dimas_Day Avatar

    I passed all the test.. but it seems that JS has error during the attempt, like -> FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory <-

    AND, I don't quite understand this error: [1:0x56268f39e000] 2775 ms: Mark-sweep 580.4 (592.2) -> 580.4 (592.2) MB, 95.0 / 0.0 ms allocation failure GC in old space requested

    please fix this.. thank you

  • rowcased Avatar
  • cupidsTrick Avatar

    This comment has been hidden.

  • Luminux Avatar

    As several people pointed out the basic tests are plain wrong! I seriously question how this mess of a kata managed to get 91% approval from the community! Wasted serious amount of time on a author mistake . . .

    Edit: After looking at the responses regarding issues in other katas from this author it seems he is truly incompetent since he refuses to solve the clear issues. It seems his idea of contribution to this website is to force the users to waste time on trivial bullshit!

  • Francisco Canhoto Avatar

    There´s errors on the basic tests, just fix this. Spent hours thinking about this until I had to unlock solutions and notice is not my mistake.

  • KenKamau Avatar

    Python translation

    Please approve.

  • didierj Avatar

    There seems to be an error for the following BasicTest for c#: 101, 9223372036854775806, 11 Expected: 838488366986797815 But was: 838488366986797791

    since 9223372036854775806 / 11 = 838488366986797800 I can't see how the expected value is higher than it

  • bouchert Avatar

    This comment has been hidden.

  • user5036852 Avatar

    C#-Translation kumited.

    https://www.codewars.com/kumite/57a098a5bb9944235a000169

    Please check and approve!

  • user5036852 Avatar

    Nice kata! Thanx!

  • aec58 Avatar

    Hey, my code works but it won't pass because: 'FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory' How do I get around this?

  • fa7ad Avatar

    This comment has been hidden.

  • duvie1 Avatar

    Why is my solution taking longer than 6000ms to complete? I only used a for loop and an if statement inside.

  • Mastermind Avatar

    Great kata!

  • adam-tokarski Avatar

    Interesting Kata! Seems so easy at first glance, that is eventually straight way to make overcomplicated solution. Thanks!

  • surtich Avatar

    This comment has been hidden.