Ad
  • Custom User Avatar

    fixed some time ago

  • Custom User Avatar

    not anymore

  • Custom User Avatar

    I'm surprised that this is quite highly voted as clever, as I wrote pretty much the exact same code and it was my first ever C# code.

  • Default User Avatar

    it's C, and I have the exact same problem...

  • Custom User Avatar

    Reasonable. Added.

  • Custom User Avatar

    Mmm... Yeah, you're right. Fixed the headings, description and the conflict.

  • Custom User Avatar

    I wonder why only version 2.4 of TypeScript is enabled?

    I was suprised to discover that I can't use Object.entries() and had to write my own object-iteration code.

  • Custom User Avatar

    I think the typescript template should at least define the parameter type. Currently it's:

    export function parseMolecule(formula) {
    

    My suggestion:

    export function parseMolecule(formula: string): Record<string,number> {
    
  • Custom User Avatar

    I suggest an additional test for a scenario where the template contains no # characters:

    (112, "+( )") => "+( )"
    
  • Custom User Avatar

    IMHO this line in description:

    You don't need to worry about validating numbers, they always have appropriate form.

    conflicts with the lines that follow:

    if there are digits in a number that can't be formated, they should be skipped.

    if there are less digits than needed, should return "Invalid phone number"

    It states that I don't have to validate numbers, and then goes on talking how to deal with numbers that don't fit the pattern, which essentially is a validation logic.

    It's also confusing to me what does "digits in a number that can't be formated" mean and how one is supposed to skip them.

    I suggest rewriting the description as follows:

    You're given phone number and template by which it should be formated.

    • If there are more digits than needed, they should be ignored.
    • If there are less digits than needed, return "Invalid phone number".

    Also, the title "Introduction" doesn't make sense when it's followed by the whole description of the problem.

  • Custom User Avatar

    Problems with typography and Markdown formatting:

    • Use # heading not ###heading###
    • No need to write headings in uppercase and followed by colon
  • Custom User Avatar

    The description should say what to do about corner cases:

    • empty string given as input
    • invalid locomotive position or multiple locomotives e.g. "_A__B"
    • other characters in the input

    I think the description should simply say:

    You can assume that input will only contain valid trains (i.e. one locomotive followed by coaches).

  • Custom User Avatar

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

  • Custom User Avatar

    Well, I haven't really come across many katas in puzzle category. So I made a search and looked into several examples, but I have to admit I saw no clear pattern. There were some code-golf problems, but also a whole lot of other things ranging from counting even numbers to implementing MineSweeper. Importantly I noticed no other problems where only one solution would be applicable.

    I also have no idea how to research for a solution to this problem. I guess one could google for "shortest code for reversing array in JavaScript", but that's just googling for the exact answer.

    But most importantly, as many others have commented, a correct solution to this kata is actually not even possible - according to description the solution should reverse an array containing any types, but the .sort() solution will fail when the array contains undefined values.

  • Custom User Avatar

    Maybe. But then, this is how every Puzzle kata works, too. Then again, if the solution can be researched (e.g. language tricks that lead to a better understanding of the internals) then there is merit after all.

  • Loading more items...