7 kyu

Indexed capitalization

3,329 of 10,612KenKamau
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • trashy_incel Avatar

    JavaScript fork (kata author inactive)

    • Node 18 + chai assertions
    • the random tests are no longer susceptible to input mutation (fixing this issue)
    • clearly spelling out in the description that out-of-bounds indices should be ignored (fixing this issue)
    • the assertion messages now include the input values for better user experience
  • Mikönig Avatar

    This comment has been hidden.

  • dcrego Avatar

    Just solved in Go.

    My solutions was assuming the array of indices was sorted based on the examples and it woked for all the solutions. I was also asuming the array contains no negative indices. But, reading the description, the assumptions were just not correct.

    About the first assumption, I suggest to either ...

    • include the assumption that the indices are sorted in the description
    • or add test cases where there are indices greater than the input string lenght before some actually valid indices.

    About the second assumption, I suggest to either ...

    • include the assumption that the indices are always positive
    • or add test cases where there are negative indices. And even better if they are placed before some actually valid indices.
  • johnbutlergames Avatar

    This comment has been hidden.

  • saudiGuy Avatar

    This comment has been hidden.

  • user6792070 Avatar

    For Lua, when I fail the first test it says this:

    "Expected objects to be the same.

    Passed in: (string) 'aBCdeF'

    Expected: (string) 'ABcdEf'"

    The passed in value and expected value have switched places within the message.

  • 66  Avatar

    Language: C++
    Test suit missing the required headers std::string/std::vector.

  • yLaWy Avatar
  • nomennescio Avatar

    Description is inaccurate; capitalization at indices outside the bounds require those indices to be ignored.

  • manikaran Avatar

    such a warm soulful kata! Thanks

  • romaxa11 Avatar

    Cool!!!...Little things)))...

  • Monika Cyprys Avatar

    In sample tests is one incorrect test Test.assertDeepEquals(capitalize("bacdef",[1,2,5]),'aBCdeF'); JavaScript

  • kireeti_ Avatar

    string = xopDjUdgHGJPoaUXWSAN

    indices = {17, 4, 7, 45, 18, 9, 13, 14, 12, 4}

    submitted = xopDJUdGHGJPOAUXWSAN

    expected = xopDJUdGHGJPO

    I tried this kata in C and one of the test cases fails.

  • Brolaf Avatar

    Hi @KenKamau, I've just noticed that mutating ind array will cause to fail at random tests (at least solving with Python). I think description should include information about mutating the input. If it doesn't I assumed I can do whatever I want with input. Apparently my assumption was wrong and my solution failed at random tests. Please consider changing one of the following:

    • leaving kata description as it is and fix random tests so user can mutate input array or
    • explicitly state in description that user is not allowed to mutate the input array

    Aparat from that the kata is great. Cheers!

  • Glaz Avatar

    It looks like, there are some warnings in Kata:

    main.cpp:33:29: warning: comparison of integers of different signs: 'int' and 'std::vector::size_type' (aka 'unsigned long') [-Wsign-compare] for (int i = 0; i < idxs.size(); ++i) ~ ^ ~~~~~~~~~~~ main.cpp:35:46: warning: comparison of integers of different signs: 'std::vector::size_type' (aka 'unsigned long') and '__gnu_cxx::__alloc_traits<std::allocator, int>::value_type' (aka 'int') [-Wsign-compare] if (idxs[i] < 0 || result.size() <= idxs[i]) ~~~~~~~~~~~~~ ^ ~~~~~~~ 2 warnings generated.

    (it's not warnings from my code)

  • E1phant Avatar

    Error in Java, when i try to test the program it mark a false with no description with number 1. (I writed "System.out.println(s)" and the same in the end of the program to see where I make false, but everything is good. I check input and output in my program and in tests. They are same.

  • rowcased Avatar

    C Translation available

  • actually reb Avatar

    The Lua function is still broken, as mentioned by spudboy. It won't work unless you remove 'local' from the function.

  • Egor_S Avatar

    This comment has been hidden.

  • jalovatt Avatar

    Error running the tests in Lua - the solution template attempts to declare a local function inside a table:

    indexcap = {}
    local function indexcap.capitalize(s,arr)
    

    Removing local fixes it.

    Also, Lua indexes from 1 by default. The sample solutions count the string positions from 0, which will probably trip a few people up. Could use a note in the description.

  • spudboy Avatar

    In Lua the function isn't exported to the tests properly by default because it's marked as local.

  • szmodry Avatar

    This comment has been hidden.

  • szmodry Avatar

    Hi, Just tried to solve in C++ and found this in random test cases:

    Test input "qesiaoxuqvz"; idxs = [87, 17, 88, 50, 67, 10, 16, 90, 31, 46]; Expected: equal to qesiaoxUQvZ Actual: qesiaoxuqvZ

    10 is the lowest index and the only valid for this string. Why 'u', 'q' are capitalized? Bug in test or different rules (index "wraps")?

  • PETARJEV Avatar

    You should also state that array "arr" does not have to be sorted. P.S. Sort the array "arr" before you use it for solutions :) .

  • Maverink Avatar

    This comment has been hidden.

  • raulbc777 Avatar

    This comment has been hidden.

  • gcohavy Avatar

    This comment has been hidden.

  • gcohavy Avatar

    This comment has been hidden.

  • k-vosswinkel Avatar

    This comment has been hidden.

  • Jarch24 Avatar

    This comment has been hidden.

  • xenoexplorator Avatar

    Just finished a Haskell translation. Feel free to approve.

  • Souzooka Avatar

    Hi @KenKamau, I made a C++ translation for your consideration here.

  • Souzooka Avatar

    This comment has been hidden.

  • Cptnprice Avatar

    capitalize("abcdef",[1,2,5]) = "aBCdEf"

    Should not it be equal to 'aBCdeF' ?