Ad
  • Custom User Avatar

    There's a way to make it one line tho :)
    One line solutions are usually not the best ones (in terms of performance and readability) but people still upvote them because they look cool

  • Custom User Avatar

    That's true. But then I'd have to do -1 in 3 places. And my two < would become <=.

  • Custom User Avatar

    Nice solution, could start your iterators at 1 to avoid the + 1

  • Custom User Avatar

    Assigning is slightly faster than pushing (~20%). Either way is fine though.

  • Custom User Avatar

    What's better? doing push() or assign a value to a nonexistent element of the array?

  • Custom User Avatar

    Being a new JS Programmer, I was becoming disillusioned with every "easy" Kata top solution being one line of Regex.
    I'm happy to finally see something very close to my answer as Best Practice.

  • Custom User Avatar

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

  • Custom User Avatar

    Poorly worded, but it must be understood that the characters are not sequential (consecutive characters are A, then B, then C, and so on)

  • Custom User Avatar

    This requirement makes no sense to me:

    Paths will not necessarily be sequential (characters can be skipped).

    Does it mean that points in a path must not be connected with each other? But this 1) contradicts test cases, 2) makes grid representation useless - the kata then is just "find longest lexicographically ordered substring in a string".

    After solving it I feel more like "paths must be proper sequential paths with every point adjacent to previous and next ones".

  • Custom User Avatar
  • Custom User Avatar

    If you don't see it as a path, but as a walk through the grid, does it make more sense? I can step on a, then on b, &c ..

    How do I encode not walking?

    ETA: Oh. That's your last comment, basically.

  • Custom User Avatar

    It could be viewed this way:
    You are standing in a location connected to all locations in the grid. How much further can you move?
    And then it makes sense to add in empty, there does exist a path of "no further".

    If viewed as "from some a to some b", where there is no a... I object.

    See this is why I argue. Sometimes I need people to share THEIR perspective >_< I did YOUR job! D:
    It's not that I'm right, it's that at least one is missing what the other sees.

  • Custom User Avatar

    A bunch of children have various ages. Which of those ages is the largest?

    >>> oldest = maximumBy compare . (0 :)
    >>> oldest []
    0  -- wait, who's got an age 0?
    

    The empty case here does not have an answer.

    Which of the paths you found is the longest?

    >>> longest = maximumBy (compare `on` length) . ([] :)
    >>> longest []
    []  -- that's not any of the paths I found.
    

    There is an imaginary path "" included when carrying out maximum.

    I lack the math background to claim to be right or do any formal arguing. If I fail to convince with what I can say. Oh well.

    Does it help if I have cookies in my trench? :(

  • Custom User Avatar

    "default for maximum" - that's an identity value. Because it's a default for maximumBy (compare `on` length <> compare `on` Down) actually. It makes a perfect identity for that.

    I was prepared to stop bickering about it and spend Christmas dug into our respective trenches until I noticed this:

    how is v ! i : (maximumBy order $ ("" :) []) not "combining with """ ? And that is the same step as between the first and second char.

    That [] would result from filter ( something ) $ [ neighbours ]; there definitely are conditions that would make that the empty list.

    But if that doesn't convince you, I am willing to retreat into my trench and leave you alone in yours. I won't even say who's right and who's wrong. ( must .. not .. but I really won't :)

  • Custom User Avatar

    You both use "" as a default for maximum, you're not finding it in the array nor combining it with a next step. Not an identity value!
    ... You collect a bunch of candidates. You also add "" in there, separately. Then you get max. If you get "" back, you say it was there all along! But it was added separately.
    In order for it to be an identity value, you'd need to be doing the same step between "" and the first char, as the first char and the second char.

  • Loading more items...