Ad
  • Custom User Avatar

    The reference solution sometimes finds the wrong solution (this happens quite rarely). Here is one expression I came across in random tests:

    const exp=
    `  CDBA
    *   D
    ------
    = 9900`
    
    // reference solution => 2475 * 4 = 9900
    // correct solution   => 1650 * 6 = 9900
    
  • Custom User Avatar

    It's incredibly satisfying to finally be finished. It wasn't easy, thanks for a great and challenging kata. IMHO, it was closer to 1kuy than to 2kuy. And I agree with comment @Voile, I think this is indeed a problem and should be taken into consideration.

  • Custom User Avatar

    I originally went your way and tried to write an algorithm with different scores and it worked, but it didn't always fit perfectly into 16 moves. Then I thought, I needed a stable solution and I thought about creating an endgame table for this problem. And actually for me it was not trivial, finding the right algorithm and implementing it to make things work relatively fast is not an easy task, especially debugging caused a lot of pain given the number of possible states. All these attempts took quite a long time, I returned to this problem intermittently for 6 months, so for me it's 1kuy. By the way funny fact, if you look at other users' solutions, about half of the solutions have hardcoded tables.

  • Custom User Avatar

    There are 20000 JS tests in total, your code handles about half of them, I have run it several times - the result is 10_000 - 12_000. To be honest, I haven't looked closely at your code and can't tell you exactly what the problem is, but your algorithm needs to be improved. However, before you change anything, maybe you can add caching for some “heavy” calculations (if there are any and it is possible), it might work.

  • Custom User Avatar

    Okay. That makes it a little clearer. Thank you. I may have more questions).

  • Custom User Avatar

    I'm not sure what your question is.

    Amines are tricky, because they can be named in two different ways. Either "ramifications+amine", or "main-chain+ramifications+amine".

    So, you have from 1 to 3 carboned chains on the N, and either all of them are named as ramifications, or one can be named as a "main chain". Here, the dimethyl part is after what looks like the main chain (ethan) so they aren't on that chain but on the N. The 1 refers to the position of the N on the main chain (since we are in "way 2" aka [ramifications on main chain]main-chain-(pos-suffix) and here, the suffix is [dimethyl]amine, kinda).

    So you end up with what's on the left of that name in the description:

    suffix-CH2-CH3  as ethan-1-suffix
    
    H3C-N-CH2-CH3   with suffix = [dimethyl]amine
        |
        CH3
    
  • Custom User Avatar

    I got to the section Amines, phosphines, arsines: and here I have another question. In the description for it says Ramifications of ramifications that there should be a pattern like this.

    positions + “-” + multiplier + “[” + subramification + “]” + radical + “yl”
    

    But in the description I see this example - ethan-1-[dimethyl]amine, can you please explain this, ramifications does not end with ...radical + “yl”?

  • Custom User Avatar

    Oh, duh! You actually found a bug: the list of prefixes isn't up to date and still contains anoyloxy instead of oyloxy...
    I'll update that, thx. (edit: done)

  • Custom User Avatar

    Thanks for the quick reply and for breaking down this example. It all makes sense. Now I realized what the mistake was. The list of prefixes in python is missing oyloxy and I just copied it and didn't double-check it)). Perhaps you could update it and be able to add that prefix or is that the way it's designed?

  • Custom User Avatar

    The name is valid.

    8-([but] [-3-yn] [oyloxy]) oct [-3,5,7-triyn] oic acid
       .....         ......... ^^^                ^^^^^^^^
    

    Is that enough?

  • Custom User Avatar

    Or is there “garbage” in the formulas and such cases should be ignored?

  • Custom User Avatar

    I remember almost nothing from chemistry class and it's a real pain to keep everything in my head, so many rules. So, I started writing a tokenizer and got stumped, I can't figure out how to parse it:

    8-but-3-ynoyloxyoct-3,5,7-triynoic acid
              ^
    

    This is where my tokenizer breaks down, because I can't figure out what to match the part after yn with. Perhaps (probably) I'm missing something from the description, I'd be grateful if you could help me.

    p.s. Don't judge strictly:))).

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar
  • Loading more items...