Ad
  • Custom User Avatar

    Just to say, I think this is a very efficient approach (if I say so myself), it seems to run faster then a lot of other solutions which have less code.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Was just thinking it could return true or false even in a null case.

    It doesn't make any sense without any context. A string neither does nor does not end with no-one-knows-what. Returning a value is just hiding an error that someone (maybe you) will have to find one day when something weird happens because of it.

    Null ending parameter is (gracefully) handled

    ?
    It's handled the same way as a null str.

  • Custom User Avatar

    Was just thinking it could return true or false even in a null case. Null ending parameter is (gracefully) handled so why not the str parameter too?

  • Default User Avatar

    It is handled: an exception is thrown. How else would you handle that?

  • Custom User Avatar

    Null 'str' parameter is unhandled though :'(

  • Custom User Avatar

    Ah ok cheers, I get it now, appreciate your time all.

  • Default User Avatar

    @dinglemouse: Thanks for your explanations and comments.

  • Default User Avatar

    On the contrary, this Kata is very precisely worded:

    Your task is to return the first longest string consisting of k consecutive strings taken in the array.

    • You are asked to look for consecutive strings (how many of the input strings to concatenate determined by k)
    • From those candidate concatenated strings you need to find the longest
    • And if there happen to be several candidate concatenated strings having the same longest length then you need to return the first one
  • Default User Avatar

    One can't say it simpler:

    Your task is to return the first longest string consisting of k consecutive strings taken in the array.

    In other words construct all strings constitued of k consecutive (following one another) strings of the array and return the first which has the longest length.

  • Custom User Avatar

    I think this description is very badly worded, perhaps its missing details or the tests are invalid, I'm doing it in Java 8 and find some of the test cases appear to contradict each other.

    My question is what is missing from the description?
    I need enough information to make it obvious why the below tests are correct, currently they appear invalid.

    1. "zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail" with 2, expects: abigailtheta
    2. "itvayloxrp","wkppqsztdkmvcuwvereiupccauycnjutlv","vweqilsfytihvrzlaodfixoyxvyuyvgpck" with 2, expects: wkppqsztdkmvcuwvereiupccauycnjutlvvweqilsfytihvrzlaodfixoyxvyuyvgpck
    3. "wlwsasphmxx","owiaxujylentrklctozmymu","wpgozvxxiu" with 2, expects: wlwsasphmxxowiaxujylentrklctozmymu
    4. "it","wkppv","ixoyx", "3452", "zzzzzzzzzzzz" with 3, expects: ixoyx3452zzzzzzzzzzzz

    1- appears to say: find the first largest string, and then take that and one more string from the array (equaling two), and that matches the description
    2- appears to match test 1
    3- this appears to say take the second largest string 'wlwsasphmxx' first and then the largest 'owiaxujylentrklctozmymu'
    4- even weirder, this appears to say take the third largest string and get the three consecutive strings from the array.. but no logic that would facilitate that is mentioned in the description.