Ad
  • Custom User Avatar

    I have the same problem... this task seems to me unclear because nothing works. I completed the easier one and I though this is in the same manner but it is senseless to guess what to do

  • Custom User Avatar

    I don't get it at all. I defined __ and __ and __ or __ methods in Specification class and in test cases I keep getting the following error:
    TypeError: unsupported operand type(s) for &: 'type' and 'type'.
    I though that Water and Hot classes inherit from Specification class... Any hint?

  • Custom User Avatar

    thanks! it helped

  • Custom User Avatar

    Please switch Python version to 3.8 and see if it helps.

  • Custom User Avatar

    I passed all of the test cases, but when I push attempt button I got:

    "Traceback (most recent call last):
    File "main.py", line 4, in
    import codewars_test as test
    ModuleNotFoundError: No module named 'codewars_test'"

    what is it about?

  • Custom User Avatar

    I passed all the test cases but I'm stuck at random test. I have to following error:

    Traceback (most recent call last):
    File "/workspace/default/src/codewars-test/codewars_test/test_framework.py", line 111, in wrapper
    func()
    File "tests.py", line 108, in it_1
    template(b, n, l)
    File "tests.py", line 95, in template
    test.expect(all(getattr(user, x) == getattr(result, x) for x in value_names), "Expected: {}\nReceived: {}".format(result, user), allow_raise=True)
    File "/workspace/default/src/codewars-test/codewars_test/test_framework.py", line 24, in expect
    raise AssertException(message)
    codewars_test.test_framework.AssertException: Expected: <main.random_tests..template..B object at 0x7fae26dbba30>
    Received: Ofrsngx(14, 10, 17)

    I cannot figure this out. Could anybody give me a hint?

  • Custom User Avatar

    About forbidding modules:
    Here is old code from one of my katas, it would give you the general idea. You need to include this code in Preloaded section. (note, that test is import codewars_test as test)

    import random
    
    toForbid  = ['importlib', '_frozen_importlib', 'os', 'sys', 'builtins',
                 '_frozen_importlib', '_frozen_importlib_external', '_imp',
                 'gc', 'json', 'requests', 'subprocess']
    
    def module_forbidder(*forbid):   
        from functools import wraps
        import re, sys
        original      = __import__
        checker       = 'extract.hlsidhgfoisHDE67678EFG2Sdyftsrtstfh'
        modulesToKeep = ('random',)
        keptModules   = tuple(__import__(name) for name in modulesToKeep)
        toForbid.extend(modulesToKeep)
        for name in modulesToKeep + ('sys',):
            del sys.modules[name]
        @wraps(__import__)
        def DontDoThis(*a,**k):
            if a[0] == checker: return keptModules
            for name in forbid:
                if re.search(r'\b{}\b'.format(name), a[0]):
                    test.fail("Don't import {} or a module that depends on it.".format(name))
                    raise Exception("Don't do this...")
            try:    return original(*a,**k)
            except: pass         
        return DontDoThis
    array_to_delete = tuple(('functools', 'itertools', 'operator', '_operator'))
    toForbid.extend(array_to_delete)
    __builtins__['__import__'] = module_forbidder(*toForbid)
    
    for func in 'eval exec open'.split():  __builtins__[func] = None
    
    del module_forbidder, toForbid, func
    
    
  • Custom User Avatar

    Now I've found the kata that concerns the Euler's method. I've been planning to create the whole series about solving systems of differential equations and I wanted to start off with something easy. Maybe I will transform the task into the system of two equations or, as rge123 suggested, I will enforce improved Euler's method.

    Answering dolamroth suggestions:

    1. I don't quite follow, I need to think this through
    2. I will change the task to be more specific

    Now I am aware that I should disable some functions but I can not figure it out. How to block a function? I know it may be a silly question but I've been trying to find this out and no success.

  • Custom User Avatar

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

  • Custom User Avatar

    I fixed that. Now the last value from the input data will be always greater than 0.1

  • Custom User Avatar

    Thanks, it was by accident. I fixed this issue.

  • Custom User Avatar

    I would suggest to make kata with differential equation, that does not have analytical solution (i.e. riccati system) and enforce large difference between y(0) and y(T). Furthermore, as Unnamed suggested, you should disable some Python modules, that allow user to cheat the kata.

  • Custom User Avatar

    I agree. There is also already a kata on Euler's method. Maybe enforce a more efficient algorithm (and defo make it non-analytical)?

  • Custom User Avatar
  • Custom User Avatar

    The reference solution times out sometimes, for example, with this input from the random tests: [4, 4, 1, -5], [0, 0.2], 0.0.

  • Loading more items...