Ad
  • Custom User Avatar

    Thank you mr replyguy, I am very well aware.

  • Custom User Avatar

    Literally cannot understand any sentence of this kata's description. Really wish this site was actually codewars and not puzzles for people who studied mathematics at university...

  • Custom User Avatar

    I just realized I totaly swapped left and right. You'd think I'd remember which one is left after 28 years...

  • Custom User Avatar

    This just barely passes the "cpu playing against itself" tests, but has a few known bugs:

    • it's unclear how to handle the win message should the player win with the move provided by the cpu
    • it's unclear if CPU and player permanently switch signs when the CPU provides a player move or if the method should force the next move() call to be for the CPU
    • it's possible for the player to perform two moves by providing a move after the CPU picked one for the player already
  • Custom User Avatar

    Next time I would prefer that instead of relying on implementation details such as ordered dicts/Maps you simply provide an array of tuplies (i.e. the result of functions.entries() in JS). the V8 engine happens to also have ordered Maps and Sets, but that is not guranteed to happen in other JS engines.

  • Custom User Avatar

    for anyone solving this currently and confused by this edgecase: The solver appears to expect the output array to grow by at least 2 on each iteration, so if your result is an empty array after trimming leading and trailing zeroes you can create a new array of list.length + 2 and fill it with zeroes.

  • Custom User Avatar

    This kata very badly needs to be updated, there are no tests anymore and while the description asks for a "generator" it does not actually mean generator functions which now exist in JavaScript.

  • Custom User Avatar

    I'd like to add that this should in theory be using a linked list instead of an array, since it's having to re-index the array on every yield, which becomes a lot of work for large sequence sizes (like the pointless sequence test). Didn't time out here, so I guess array is acceptable :)

  • Custom User Avatar

    technically creates extra numbers, but I like how small this solution is without becoming an unreadable nightmare like 99% of the "best" solutions on here. Great work!

  • Custom User Avatar

    While trying to debug my solution I managed to find out that codewars allows for the injection of arbitary HTML via console.log. At least it removes script tags, so there's no immediatly obvious XSS vulnerability here. Still super annoying since it means I'll need to sanitize my own logs now.

    For reference here is the log function I used for debugging my solution:

    function ___log(text) {
      console.log(text.replace(/["'<>&]/gi, c => `&#${c.charCodeAt(0)};`));
    }
    
  • Custom User Avatar

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

  • Custom User Avatar

    Not going to lie, I am not going to bother with these Kata simply because there is no description. I am here to practice problem solving and implementing solutions and not play a guessing game.

  • Custom User Avatar

    In theory this is the best practice because it makes use of existing and tested code that's clearly available here.

  • Custom User Avatar

    The description quite literally says "given an array of integers", yet one test gives null as the input, which results in TypeError: Cannot read property 'length' of null when correctly assuming that you always get an array (as per description) and merely need to test for its length.

  • Custom User Avatar

    Solutions like this one that modify the arguments should be banned. This causes unintended sideeffects by modifying any objects passed. Please clone objects before modifying!