Ad
  • 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.

  • 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

    What I mean is that there's no way to solve this in a better or worse way. You either solve it in the one-and-only way or you won't be able to solve it at all. There's no middle-ground. There's nothing to learn from looking at other solutions and seeing how they compare to yours, as all the solutions are the same. You won't come back to this problem on another day to see if you could do better. I think this problem completely misses the spirit of katas.

  • Custom User Avatar

    This is the worst kata I've experienced. You either know the expected solution or you don't. Nothing to learn from this.

  • Custom User Avatar

    I have trouble understanding the description:

    1. Operations are infinite
    2. Order of operations is imperitive [sic]

    My guess is that the author meant the following:

    1. There can be any number of operations
    2. Order of operations is important.
  • Custom User Avatar

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