Ad
  • Custom User Avatar
  • Custom User Avatar

    Fork here which addresses the following problems in JS:

    1. Test max now matches description
    2. Initial solution function signature fixed
    3. Node version updated to 18.x
    4. Test library updated to chai
    5. Tests are no longer in code-golf style formatting (why was this even a thing?)
  • Custom User Avatar

    The details define the boundaries as "Given a number as a parameter (between 2 and 30)", while in reality the tests contain the values up to 100.

  • Custom User Avatar

    Yes, it passes the "Remove empty branches, after unlocking" section.
    Though, the solution is submitted now, I was experiencing random failures of 1-2 random tests and that's where I couldn't spot, what the issue is :-|

  • Custom User Avatar

    ok, one part (at least...) of the spec is missing for the branch removal. You're supposed make the branches "contiguous again", after removal of empty branches. Aka, if you remove branch 3, branch 4 is now considered branch 3. (edit: added to the description)

    Does your code pass the tests in the Remove empty branches, after unlocking section? because that's where this behavior is tested.

  • Custom User Avatar

    To further clarify, I'm doing this kata using Ruby, the solution passes all the basic tests, around 20% of the random tests, and just one (Throw an EmptyMolecule exception when no branches are left after unlocking) test out of the "Behaviors related to the "unlock" method" section.
    Another question: should the branches be renumbered as well and if yes - should this happen during the "unlock" or upon mutation of the branch first element?

    Update: It seems that I got it, all the Hydrogens suppose to be removed regardless whether they are added on "closer" or mutated, so now my solution passes all the non-random tests, however it passes only 20 to 30% of random tests, hence the question - how do I properly debug that given that the outcome of the tests is truncated and the visible part seems to be equal?

    expected: ["Atom(O.1: C13,Cl16)", "Atom(O.2: C3)", "Atom(C.3: C4,C18,O2)", "Atom(C.4: C3,C5)", "Atom(C.5: C4,C6....23: C22,C24)", "Atom(C.24: C23,C25)", "Atom(C.25: C24,C26)", "Atom(C.26: C25)", "Atom(Mg.27: C19)"]
         got: ["Atom(O.1: C13,Cl16)", "Atom(O.2: C3)", "Atom(C.3: C4,C18,O2)", "Atom(C.4: C3,C5)", "Atom(C.5: C4,C6....23: C22,C24)", "Atom(C.24: C23,C25)", "Atom(C.25: C24,C26)", "Atom(C.26: C25)", "Atom(Mg.27: C19)"]
    

    More specific question is about the following sequence of events:

    molecule = Molecule.new
    molecule.brancher(7,5)
    molecule.mutate([3, 2, "P"],[5, 1, "Br"],[7, 1, "S"])
    molecule.bounder([3, 2, 2, 2],[6, 1, 2, 2],[1, 2, 2, 2],[1, 1, 4, 2])
    molecule.closer()
    

    My code throws an InvalidBond exception on the attempt to mutate to Br and therefore ignores mutation to S.
    As an outcome of these events, my code returns formula as C11H22P and molecule.atoms as

    [Atom(C.1: C2,H,H,H),
     Atom(C.2: C1,C3,H,H),
     Atom(C.3: C2,C4,H,H),
     Atom(C.4: C3,C5,H,H),
     Atom(C.5: C4,C6,H,H),
     Atom(C.6: C5,C7,C9,H),
     Atom(C.7: C6,H,H,H),
     Atom(C.8: C9,C9,H,H),
     Atom(C.9: C6,C8,P10,P10),
     Atom(P.10: C9,C9,C11),
     Atom(C.11: C12,P10,H,H),
     Atom(C.12: C11,H,H,H),
     Atom(H.13: C1),
     Atom(H.14: C1),
     Atom(H.15: C1),
     Atom(H.16: C2),
     Atom(H.17: C2),
     Atom(H.18: C3),
     Atom(H.19: C3),
     Atom(H.20: C4),
     Atom(H.21: C4),
     Atom(H.22: C5),
     Atom(H.23: C5),
     Atom(H.24: C6),
     Atom(H.25: C7),
     Atom(H.26: C7),
     Atom(H.27: C7),
     Atom(H.28: C8),
     Atom(H.29: C8),
     Atom(H.30: C11),
     Atom(H.31: C11),
     Atom(H.32: C12),
     Atom(H.33: C12),
     Atom(H.34: C12)] 
    

    which is considered invalid, but I'm wondering what is a valid result, so that I could try to debug my code.

    Okay, I found an issue in my code where I didn't remove the improperly created bond on one side when it failed on the other side, but now I have the problem that my solution fails randomly for 1-2 of random tests, though may pass if I try "attempt" several times.

  • Custom User Avatar

    I cannot look into this right now. But maybe the thread just below yours might help (a bit)

  • Custom User Avatar

    @Blind4Basics, I'm struggling with the unlock method - it says "Hydrogens should be removed, as well as any empty branch you might encounter during the process.", but it doesn't specify if this applies only to the Hydrogens that were added during the closer method or any Hydrogens including the ones that were added via add, add_chaining and mutate.
    The tests aren't explicit enough to understand what exactly is wrong with the molecule in the 'Behaviors related to the "unlock" method' section.
    I've tried different approaches (deleting all Hydrogens vs deleting only the ones that were added by closer), but the tests starting from All hydrogens should have been removed after closing/unlocking and carbons ids modified accordingly fail anyway.
    Any hint/clarification on the unlock method expected behavior?

  • Custom User Avatar

    @Erhu, proving that sudoku has multiple solution may be done in different ways and one of them is not that time-consuming.
    Think of what it means that there are several solutions in terms of the resulting elements positions & values.

  • Custom User Avatar

    AFAIU, if you have a sudoku with zero empty (zeroed) cells, which doesn't require to be solved, it should be marked as invalid.

  • Custom User Avatar

    I'd say that there's not enough tests for a larger inputs (e.g. at least 10^6+ elements).

  • Custom User Avatar
  • Custom User Avatar

    You're right, 3*9 = 27, £ == -1, so 27+(-1) == 26

  • Custom User Avatar

    "For example, the number 26 as an input should return 3^"
    Is this correct or should it be '3£' ?

  • Custom User Avatar

    The description or basic tests are lacking the examples of the sentences, because initially the user may think that "vs" is the only type of thing to appear between the team names.

  • Loading more items...