8 kyu

Multiple of index

10,804 of 23,680Dmitry Kudla
Description
Loading description...
Fundamentals
Arrays
  • Please sign in or sign up to leave a comment.
  • Ciandelahunty Avatar

    Fun Kata but ought to be 7 Kyu

  • Dave737 Avatar

    I would not say its 8kyu more like 7

  • Sagittarius_A76 Avatar

    The first index should never be counted. Because division by zero is an indeterminacy. Please correct the tests.

  • ptd3v Avatar

    This was insane to figure out and the description was useless.

  • ThatTriangleGuy Avatar

    0 is not a multiple of 0. You can't divide by 0.

  • nestorman Avatar

    I'm misunderstanding the concept of multiplicity where you can't divide by zero or the autor didn't consider his example correctly ? assertArrayEquals(new int[]{0, 2, 6}, ZywOo.multipleOfIndex(new int[]{0, 2, 3, 6, 9}));

  • Nikita0x Avatar

    what do I need to do? the description is so vague

  • KayleighWasTaken Avatar
  • KEVINPRACTICEYUAN Avatar

    This comment has been hidden.

  • Some of the Things Avatar

    Description says to create a new array but you can pass the kata by manipulating the existing array.

  • PR3SS F Avatar

    A very enjoyable task setup for the given level

  • zongronghuang Avatar

    This comment has been hidden.

  • Arsenator Avatar

    Ive no idea what it wants me to do

  • ManasviJ Avatar

    I'm working on this Kata in Java and the first test case I am getting a standard error because the size of the array is not defined. Is there any solution for this problem or is it a bug? I'm confused and I would appreciate all the help that I can get. Thank you.

  • Greenox Avatar

    It works on my VS22 but I can't test my code here and I can't get why. It says: src/Solution.cs(12,22): error CS8652: The feature 'target-typed object creation' is currently in Preview and unsupported. To use Preview features, use the 'preview' language version.

  • Chrono79 Avatar

    The user can mutate the input in random tests in at least javascript version.

  • user2549966 Avatar

    in JavaScript, the random test cases seem off?

    see: Testing №4

    for [5,79,81,-60,-83,85,-19]

    index: 0 1 2 3 4 5 6

    divisible by index are: 79 (÷1), -60 (÷3), 85(÷5) yet the expected is: '[79, -60]'

    Shouldn't it be [79, -60, 85]

    Other test cases also seem to have the similar issue

  • meridas Avatar

    This comment has been hidden.

  • MalwinaK Avatar

    Why I can not us LinkedList?

    I solved the problem. Still test fails because of using LikedList.

  • programming is life Avatar

    The examples arn't that obvious for a 8 kyu. I would really appreciate if you could explain [22, -6, 32, 82, 9, 25] => [-6, 32, 25], as since -6 is multiple by its index -1, 32 is multiple by its index 2, 25 is multiple by its index 5. Thank you

  • Soham07 Avatar

    It isn't the index, rather the position of an element in the list. Consider for example the test case [68, -1, 1, -7, 10, 10] => [-1, 10] The index of 10 in the array is always 4. But in that case the result array shouldn't contain 10 since 10 is not divisible by 4. But if we consider the position of second 10 in the array, which is 5, 10 is indeed a multiple of 5, so we consider it in our result. Please make the necessary changes.

  • Unnamed Avatar

    Julia: the example in the description uses 0-based indexing, which is different from the tests.

  • ejini战神 Avatar

    Coffeescript

    Crystal

    Julia

    (author inactive)

  • lova Avatar

    I think Go tests are a bit broken. I see some multiple values repeating, or last value duplicates. Some tests are OK. For example:

    Testing №4 for [-10 -11 22 -45 2 60 -11] Expected <[]int | len:4, cap:7>: [-11, 22, -45, 60] to equal <[]int | len:5, cap:8>: [-11, 22, -45, 60, 60]

    Testing №6 for [68 49 96 -44 -25 46 -2 -14 -53 17 -44 -99 -85 18 99 60 53 -31 -54] Expected <[]int | len:6, cap:31>: [49, 96, -14, -99, 60, -54] to equal <[]int | len:8, cap:8>: [49, 96, 60, -54, -14, -99, 60, -54]

    Testing №7 for [-92 37 50 -26 -97 87 -4 59 -63 81 -63 89 -24 71 -48 72 6 -76] Expected <[]int | len:4, cap:31>: [37, 50, 81, -24] to equal <[]int | len:6, cap:8>: [37, 50, 81, -24, 81, -24]

  • zdreagin Avatar

    The example given in the description implies that the returned array should not contain duplicate values, however the Random test case seems to expect duplicate values to be included, as it will tell me that the length of my returned array is one less than the expected length. If I return an array with duplicate values, however, my code doesn't pass the other test cases. This means that my code will sometimes pass all of the tests, but fails the Random test case when the same number is included twice in the original array, and is a multiple of both indices where it is stored. It's possible that there is another issue, since the error message doesn't actually tell me the expected contents for the returned array, but this is the only explanation I have been able to come up with.

    I only tried this Kata in Java, so I don't know if this is an issue in other languages as well.

  • ZywOo Avatar

    Java Translation

    Please approve it!)

  • kenplaysviola Avatar

    I don't understand the instructions and the examples aren't helping me understand. Can someone clarify the instructions?

    "Return a new array consisting of elements which are multiple of their own index in input array (length > 1)."

    Example: [22, -6, 32, 82, 9, 25] => [-6, 32, 25]

    In the resulting array [-6, 32, 25], how did those elements get chosen? For the firt one, element -6 * index 1 = -6? Then why is the second one 32, and the last one 25?

  • JohanWiltink Avatar

    ( Haskell, possible others - not JS though )

    Description specifies length > 1. Haskell generates random test cases with length >= 0.

  • StefanPochmann Avatar

    Bug in judge and missing test case: 0 is a multiple of 0, so a 0 at index 0 needs to be reported. Many (most?) "solutions" don't, including the judge's "solution". And there is no such test case. At least that's the situation in JavaScript, Python and Go.

    Update: In Ruby there is such a test case, and my solution gets rejected because of that.

  • javisp91 Avatar

    This comment has been hidden.

  • jakub.kurpiewski Avatar

    This comment has been hidden.

  • jaysonesmith Avatar

    The Go translation doesn't correctly start with package kata and the sample tests don't work but the official submission does

    Test Results:
    Build Failed
    STDERR:
    # codewarrior/kata_test
    ./kata_test.go:9: imported and not used: "codewarrior/kata"
    ./kata_test.go:13: undefined: multipleOfIndex
    ./kata_test.go:14: undefined: multipleOfIndex
    ./kata_test.go:15: undefined: multipleOfIndex
    ./kata_test.go:16: undefined: multipleOfIndex
    ./kata_test.go:17: undefined: multipleOfIndex
    ./kata_test.go:18: undefined: multipleOfIndex
    
  • AnielaMW Avatar

    This comment has been hidden.

  • KenKamau Avatar

    Haskell translation Kumited

    Please review and approve.

  • KenKamau Avatar

    Python translation Kumited.

    Please review and approve.

  • KenKamau Avatar

    Ruby translation Kumited

    Please review and approve.

  • Voile Avatar

    0-indexed should be mentioned in the descriptions (some languages use 1-indexed arrays instead).