Ad
  • Default User Avatar
  • Default User Avatar

    Hi,

    Considering the rank of the kata, you should be able to get all the calls one way or another, but since it seems there is a problem and you're using python, define this at the beginning of your code: TRACE_CALLS = True. You'll have the complete trace so we'll be able to check what is incorrect. Come again with the assertion message and the complete trace of the calls, please.

    Cheers

  • Default User Avatar

    Sorry, I've been busy and haven't had the chance to get back to this.

    I'm basically saying that my code works fine everywhere except two random cases in your random tester. One is where somehow some atoms in the molecule are out of sync with the rest of the atoms, printing out that they're bonded to atoms incorrectly. The other is where an molecule appears to have been closed but one carbon is missing a hydrogen.

    ['Atom(C.1: C2,C2,C21,B14)', 'Atom(C.2: C1,C1,Br34,S3)', 'Atom(S.3: C2,C4)', 'Atom(C.4: S3,H,H,H)', 'Atom(C.5: C6,H,H,H)', 'Atom(C.6: C5,C7,H,H)', 'Atom(C.7: C6,C8,H,H)', 'Atom(C.8: C7,C9,H,H)', 'Atom(C.9: C8,C10,S15,H)', 'Atom(C.10: C9,C11,H,H)', 'Atom(C.11: C10,C12,H,H)', 'Atom(C.12: C11,H,H,H)', 'Atom(Br.13: H)', 'Atom(B.14: C1,H,H)', 'Atom(S.15: C9,Mg16)', 'Atom(Mg.16: O17,S15)', 'Atom(O.17: Mg16,H)', 'Atom(C.18: C19,B52,H,H)', 'Atom(C.19: C18,C20,C26,H)', 'Atom(C.20: C19,C21,H,H)', 'Atom(C.21: C1,C20,Mg31,H)', 'Atom(C.22: C23,H,H,H)', 'Atom(C.23: C22,C24,H,H)', 'Atom(C.24: C23,C25,B30,H)', 'Atom(C.25: C24,C26,H,H)', 'Atom(C.26: C19,C25,C27,C49)', 'Atom(C.27: C26,C28,H,H)', 'Atom(C.28: C27,C29,H,H)', 'Atom(C.29: C28,H,H,H)', 'Atom(B.30: C24,H,H)', 'Atom(Mg.31: C21,B32)', 'Atom(B.32: C33,Mg31,H)', 'Atom(C.33: B32,H,H,H)', 'Atom(Br.34: C2)', 'Atom(C.35: C36,H,H,H)', 'Atom(C.36: C35,C37,H,H)', 'Atom(C.37: C36,C38,H,H)', 'Atom(C.38: C37,C39,H,H)', 'Atom(C.39: C38,C40,H,H)', 'Atom(C.40: C39,C41,H,H)', 'Atom(C.41: C40,C42,H,H)', 'Atom(C.42: C41,H,H,H)', 'Atom(C.43: C44,H,H,H)', 'Atom(C.44: C43,C45,H,H)', 'Atom(C.45: C44,C46,P53,H)', 'Atom(C.46: C45,C47,P51,H)', 'Atom(C.47: C46,C48,H,H)', 'Atom(C.48: C47,H,H,H)', 'Atom(C.49: C26,Cl50,H,H)', 'Atom(Cl.50: C49)', 'Atom(P.51: C46,H,H)', 'Atom(B.52: C18,H,H)', 'Atom(P.53: C45,H,H)', 'Atom(C.54: C55,H,H)', 'Atom(C.55: C54,H,H,H)'] should equal ['Atom(C.1: C2,C2,C21,B14)', 'Atom(C.2: C1,C1,Br34,S3)', 'Atom(S.3: C2,C4)', 'Atom(C.4: S3,H,H,H)', 'Atom(C.5: C6,H,H,H)', 'Atom(C.6: C5,C7,H,H)', 'Atom(C.7: C6,C8,H,H)', 'Atom(C.8: C7,C9,H,H)', 'Atom(C.9: C8,C10,S15,H)', 'Atom(C.10: C9,C11,H,H)', 'Atom(C.11: C10,C12,H,H)', 'Atom(C.12: C11,H,H,H)', 'Atom(Br.13: H)', 'Atom(B.14: C1,H,H)', 'Atom(S.15: C9,Mg16)', 'Atom(Mg.16: O17,S15)', 'Atom(O.17: Mg16,H)', 'Atom(C.18: C19,B52,H,H)', 'Atom(C.19: C18,C20,C26,H)', 'Atom(C.20: C19,C21,H,H)', 'Atom(C.21: C1,C20,Mg31,H)', 'Atom(C.22: C23,H,H,H)', 'Atom(C.23: C22,C24,H,H)', 'Atom(C.24: C23,C25,B30,H)', 'Atom(C.25: C24,C26,H,H)', 'Atom(C.26: C19,C25,C27,C49)', 'Atom(C.27: C26,C28,H,H)', 'Atom(C.28: C27,C29,H,H)', 'Atom(C.29: C28,H,H,H)', 'Atom(B.30: C24,H,H)', 'Atom(Mg.31: C21,B32)', 'Atom(B.32: C33,Mg31,H)', 'Atom(C.33: B32,H,H,H)', 'Atom(Br.34: C2)', 'Atom(C.35: C36,H,H,H)', 'Atom(C.36: C35,C37,H,H)', 'Atom(C.37: C36,C38,H,H)', 'Atom(C.38: C37,C39,H,H)', 'Atom(C.39: C38,C40,H,H)', 'Atom(C.40: C39,C41,H,H)', 'Atom(C.41: C40,C42,H,H)', 'Atom(C.42: C41,H,H,H)', 'Atom(C.43: C44,H,H,H)', 'Atom(C.44: C43,C45,H,H)', 'Atom(C.45: C44,C46,P53,H)', 'Atom(C.46: C45,C47,P51,H)', 'Atom(C.47: C46,C48,H,H)', 'Atom(C.48: C47,H,H,H)', 'Atom(C.49: C26,Cl50,H,H)', 'Atom(Cl.50: C49)', 'Atom(P.51: C46,H,H)', 'Atom(B.52: C18,H,H)', 'Atom(P.53: C45,H,H)', 'Atom(C.54: C55,H,H,H)', 'Atom(C.55: C54,H,H,H)']

    From my perspective these issues should've come up in the normal tests, so since they didn't either (a) the random tester is doing something really weird, or (b) the normal set of tests needs more tests.

    It's really really hard for me to get the exact functions that were run b/c the random tester doesn't seem to print to std out? I can only get info out of std error, but need to know the error first. Bit frustrating, need to know the bug so I can fix it.

  • Default User Avatar

    Well, no news, closing. Feel free to continue the discussion if needed, of course.

  • Default User Avatar

    I checked by hand only: Are you sure you didn't misspelled something in your example? because I end up with the following:

    m = Molecule().brancher(5, 4, 5).mutate((3, 1, 'C'), (2, 3, 'N'), (5, 3, 'S')).brancher(4, 2, 7).bounder((5, 3, 4, 4), (4, 3, 2, 5)).mutate((3, 1, 'O'),).add_chaining(2, 5, 'B', 'Br').brancher(1, 5).add((2, 1, 'Br'),)
    
    
                     |-------------|
                     |             |
           1     6   | 10     15   | 19       21     30     31
    (Br)36-2     7   | 11(N)  16   |-20-      22            32
           3(O)  8   | 12     17       |      23            33
           4     9   |-13     18       28(B)  24            34
           5           14(S)  |        |      25            35
                        |-----|        29(Br) 26            
                                              27            
    

    So C5 isn't linked to S14 as you wrote above (-> Atom(C.5: S14, C4)).

    About this: Seems that my code has Atom(C.15: C14,C16,C16) in a closed molecule which should be Atom(C.15: C14,C16,C16,H) it's hard to say without the steps. A lot could happen at different steps before explaining the problem in different ways (atom mutated to H so at this step you have an unlocked molecule? Or is the molecule locked? ...?).

  • Default User Avatar

    Hi,

    Thx for letting me know. I'll look into the whole thing later today.

    About the exceptions, did you see the last foot note? => About the required exceptions classes, you can implement subclasses if you want, but their names will have to contain the name of the one originally expected.

    And I'm not sure what you mean by an unmutated exception. Are you talking about subclasses, actually? But you are true about one point: this is suboptimal. If I had to do that again, I'd provide the exceptions so that I could always use the same manner to check for them. The thing is I didn't want to relay on the exceptions of the user (it could have been a way to cheat, even if not on purpose), and since I couldn't predict what would be the exceptions in the random tests, I needed my own set of them. That caused the mess.

    I'll keep you posted.

  • Default User Avatar

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

  • Default User Avatar

    a few opinions:

    1. it's nice that the grid is subscribable, but i think it'd be cleaner to make each node callable by position e.g. grid.node(x,y) = True
    2. position property should return a tuple, not have a property within itself called x; why is there a class within a class?
    3. can you please work on getting this compatible with py3??? which would be way more efficient for this kind of problem
  • Default User Avatar

    This kata should have some time complexity optimization in it. As it stands right now it's way too simple.

  • Default User Avatar

    I also have this same issue.

  • Custom User Avatar

    This is a Codewars issue not an issue with the Kata.

  • Custom User Avatar

    Thanks this Kata was published before Codewars offered Python 3 and it just made it out of Beta. I have updated using range instead of xrange. This issue should be resolved.

  • Default User Avatar

    This should be straightforward with python3's standard statistics module, but the grader seems to use xrange which doesn't exist in python3.

  • Default User Avatar

    Some sort of strange problem returning an out of range for Enumerable.Repeat with the count parameter in the example. Doubtful that the exaple is larger than the max range of Repeat()???