Ad
  • Custom User Avatar

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

  • Custom User Avatar

    The problem was with my code indeed! I simplified the solution and it passed normally on Codewars now.

    I have my local repo setup with TS, mocha and ts-node and I execute the test task in package.json to verify that all tests pass.

      ...
      "test": "mocha \"test/**/*.{ts,js}\" --recursive -r \"ts-node/register\" -r \"tsconfig-paths/register\"",
      ...
    

    It's with this setup that my erroneous code passed and I want to investigate further why that was the case.
    When I executed via a classic node cli terminal locally, it threw the same memory error as Codewars did!

    I will post here my findings when I find out what magic did the TS compiler and my code passed in the first iteration.

  • Custom User Avatar

    It throws this error even with the sample tests which use simple and small arrays. The same sample tests and even more complicated ones with object references pass with flying colors locally. This memory error is very strange. That's why I posed the question tentatively and not marked as an issue.

  • Custom User Avatar

    I've authored a JS solution that works on my machine (at least for various cases that I created and the sample tests provided), however when trying on CodeWars I get this stacktrace:

    <--- Last few GCs --->
    
    [1:0x563c8a521000]     3487 ms: Mark-sweep 580.5 (592.2) -> 580.5 (592.2) MB, 198.8 / 0.0 ms  allocation failure GC in old space requested
    [1:0x563c8a521000]     3686 ms: Mark-sweep 580.5 (592.2) -> 580.4 (585.2) MB, 199.4 / 0.0 ms  last resort GC in old space requested
    [1:0x563c8a521000]     3888 ms: Mark-sweep 580.4 (585.2) -> 580.4 (585.2) MB, 201.4 / 0.0 ms  last resort GC in old space requested
    
    
    <--- JS stacktrace --->
    
    ==== JS stack trace =========================================
    
    Security context: 0x2ef7f64a57c1 <JSObject>
        1: combine [/home/codewarrior/index.js:~5] [pc=0x371d80b0c4e2](this=0x15be678c211 <JSGlobal Object>)
        2: arguments adaptor frame: 4->0
        3: /* anonymous */ [/home/codewarrior/index.js:36] [bytecode=0x3b47ab84d949 offset=222](this=0x15be678c211 <JSGlobal Object>)
        4: /* anonymous */ [/runner/frameworks/javascript/cw-2.js:152] [bytecode=0x3b47ab846851 offset=145](this=0x15be678c211 <JS...
     
     STDERR
    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
    

    Can someone please tell me if this error originates from my code or it's a CodeWars platform error?
    The general error at the end reads "JavaScript heap out of memory" yet I am not using memory intensively, working with indices mostly, nor am I modifying input arrays.

  • Custom User Avatar

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

  • Custom User Avatar

    Pff! I think the only think he revised was the kata's rank (from 4 to 5). I misread the revisions: https://www.codewars.com/kata/neutralization-reaction/revisions

    It is my 2nd published kata (and the first to be ranked) so forgive my nervousness and ignorance.

  • Custom User Avatar

    Ok, I'm approving the translation. Please review the updated code because I think Voile, who approved the kata, made a lot of changes and I didn't have time to see what changed. :)
    Thank you for your contribution!

  • Custom User Avatar

    Your translation seems fine and I want to approve it, but I want to ask you something first.

    I have fine tuned the test cases for the JS version, namely all test cases have guaranteed shuffled acid, bases data sets and explicit tests for NH4OH, which is a unique base and could be missed during the shuffling and slicing of the data. However, due to codewars' technical issues my republishing efforts seem to be constantly timing out.

    Do you think that if I approve this version it will be possible for you to republish the updated tests later on or will it be as difficult for you as it is for me and we must wait a while until things smooth out on codewars' back-end?

  • Custom User Avatar

    To save an easily accessable bookmark to your currently working kata you can add a star (top-left star link under the kata's name) or add it to a custom collection.

    Either way the kata's you have ever worked on (attempted to provide a solution) and are incomplete are saved in your profile page under the Kata section in the Unfinished tab.

    Notice that if you want the partial solution to be saved along with the reference to the kata, you must hit the Attempt button at least one time. If you run only the local test cases the partial solution will not be saved. At least this is how it worked so far and this may be subject to change.

  • Custom User Avatar

    Since you edited your response and my comment became obsolete, I edited it too to stay relevant in its context.
    Do you think that it is worth investing some time into setting more semantic names for functions and their arguments?

  • Custom User Avatar

    ...and the prize for the most unimaginative solution function name of the year (i.e. "solve") goes to... this kata!
    Other than that, however, it was a nice challenge. Congrats! :D

    PS: Actually there are several other katas sharing the same generic solution naming practices, but I thought I would just drop my comment on this one, because someone has to do it I guess.

  • Custom User Avatar
  • Custom User Avatar

    Consider renaming all references of circle with circumcircle (or circumscribed circle). This is the proper name for the unique circle that touches every vertex in the polygon, and in which we are interested. Other than that I enjoyed this kata! :)

  • Custom User Avatar

    Java translation kumited. Please approve.

  • Custom User Avatar

    Try a regex that targets that last ',' and replace it in the formatted string or use lastIndexOf(',') to the same effect.

  • Loading more items...